LLVM  10.0.0
Scalarizer.cpp
Go to the documentation of this file.
1 //===- Scalarizer.cpp - Scalarize vector operations -----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This pass converts vector operations into scalar operations, in order
10 // to expose optimization opportunities on the individual scalar operations.
11 // It is mainly intended for targets that do not have vector units, but it
12 // may also be useful for revectorizing code to different vector widths.
13 //
14 //===----------------------------------------------------------------------===//
15 
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/Twine.h"
21 #include "llvm/IR/Argument.h"
22 #include "llvm/IR/BasicBlock.h"
23 #include "llvm/IR/Constants.h"
24 #include "llvm/IR/DataLayout.h"
25 #include "llvm/IR/Dominators.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/Function.h"
28 #include "llvm/IR/IRBuilder.h"
29 #include "llvm/IR/InstVisitor.h"
30 #include "llvm/IR/InstrTypes.h"
31 #include "llvm/IR/Instruction.h"
32 #include "llvm/IR/Instructions.h"
33 #include "llvm/IR/Intrinsics.h"
34 #include "llvm/IR/LLVMContext.h"
35 #include "llvm/IR/Module.h"
36 #include "llvm/IR/Type.h"
37 #include "llvm/IR/Value.h"
38 #include "llvm/InitializePasses.h"
39 #include "llvm/Pass.h"
40 #include "llvm/Support/Casting.h"
43 #include "llvm/Transforms/Scalar.h"
44 #include <cassert>
45 #include <cstdint>
46 #include <iterator>
47 #include <map>
48 #include <utility>
49 
50 using namespace llvm;
51 
52 #define DEBUG_TYPE "scalarizer"
53 
54 // This is disabled by default because having separate loads and stores
55 // makes it more likely that the -combiner-alias-analysis limits will be
56 // reached.
57 static cl::opt<bool>
58  ScalarizeLoadStore("scalarize-load-store", cl::init(false), cl::Hidden,
59  cl::desc("Allow the scalarizer pass to scalarize loads and store"));
60 
61 namespace {
62 
63 // Used to store the scattered form of a vector.
64 using ValueVector = SmallVector<Value *, 8>;
65 
66 // Used to map a vector Value to its scattered form. We use std::map
67 // because we want iterators to persist across insertion and because the
68 // values are relatively large.
69 using ScatterMap = std::map<Value *, ValueVector>;
70 
71 // Lists Instructions that have been replaced with scalar implementations,
72 // along with a pointer to their scattered forms.
74 
75 // Provides a very limited vector-like interface for lazily accessing one
76 // component of a scattered vector or vector pointer.
77 class Scatterer {
78 public:
79  Scatterer() = default;
80 
81  // Scatter V into Size components. If new instructions are needed,
82  // insert them before BBI in BB. If Cache is nonnull, use it to cache
83  // the results.
84  Scatterer(BasicBlock *bb, BasicBlock::iterator bbi, Value *v,
85  ValueVector *cachePtr = nullptr);
86 
87  // Return component I, creating a new Value for it if necessary.
88  Value *operator[](unsigned I);
89 
90  // Return the number of components.
91  unsigned size() const { return Size; }
92 
93 private:
94  BasicBlock *BB;
96  Value *V;
97  ValueVector *CachePtr;
98  PointerType *PtrTy;
99  ValueVector Tmp;
100  unsigned Size;
101 };
102 
103 // FCmpSpliiter(FCI)(Builder, X, Y, Name) uses Builder to create an FCmp
104 // called Name that compares X and Y in the same way as FCI.
105 struct FCmpSplitter {
106  FCmpSplitter(FCmpInst &fci) : FCI(fci) {}
107 
108  Value *operator()(IRBuilder<> &Builder, Value *Op0, Value *Op1,
109  const Twine &Name) const {
110  return Builder.CreateFCmp(FCI.getPredicate(), Op0, Op1, Name);
111  }
112 
113  FCmpInst &FCI;
114 };
115 
116 // ICmpSpliiter(ICI)(Builder, X, Y, Name) uses Builder to create an ICmp
117 // called Name that compares X and Y in the same way as ICI.
118 struct ICmpSplitter {
119  ICmpSplitter(ICmpInst &ici) : ICI(ici) {}
120 
121  Value *operator()(IRBuilder<> &Builder, Value *Op0, Value *Op1,
122  const Twine &Name) const {
123  return Builder.CreateICmp(ICI.getPredicate(), Op0, Op1, Name);
124  }
125 
126  ICmpInst &ICI;
127 };
128 
129 // UnarySpliiter(UO)(Builder, X, Name) uses Builder to create
130 // a unary operator like UO called Name with operand X.
131 struct UnarySplitter {
132  UnarySplitter(UnaryOperator &uo) : UO(uo) {}
133 
134  Value *operator()(IRBuilder<> &Builder, Value *Op, const Twine &Name) const {
135  return Builder.CreateUnOp(UO.getOpcode(), Op, Name);
136  }
137 
138  UnaryOperator &UO;
139 };
140 
141 // BinarySpliiter(BO)(Builder, X, Y, Name) uses Builder to create
142 // a binary operator like BO called Name with operands X and Y.
143 struct BinarySplitter {
144  BinarySplitter(BinaryOperator &bo) : BO(bo) {}
145 
146  Value *operator()(IRBuilder<> &Builder, Value *Op0, Value *Op1,
147  const Twine &Name) const {
148  return Builder.CreateBinOp(BO.getOpcode(), Op0, Op1, Name);
149  }
150 
151  BinaryOperator &BO;
152 };
153 
154 // Information about a load or store that we're scalarizing.
155 struct VectorLayout {
156  VectorLayout() = default;
157 
158  // Return the alignment of element I.
159  uint64_t getElemAlign(unsigned I) {
160  return MinAlign(VecAlign, I * ElemSize);
161  }
162 
163  // The type of the vector.
164  VectorType *VecTy = nullptr;
165 
166  // The type of each element.
167  Type *ElemTy = nullptr;
168 
169  // The alignment of the vector.
170  uint64_t VecAlign = 0;
171 
172  // The size of each element.
173  uint64_t ElemSize = 0;
174 };
175 
176 class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
177 public:
178  ScalarizerVisitor(unsigned ParallelLoopAccessMDKind, DominatorTree *DT)
179  : ParallelLoopAccessMDKind(ParallelLoopAccessMDKind), DT(DT) {
180  }
181 
182  bool visit(Function &F);
183 
184  // InstVisitor methods. They return true if the instruction was scalarized,
185  // false if nothing changed.
186  bool visitInstruction(Instruction &I) { return false; }
187  bool visitSelectInst(SelectInst &SI);
188  bool visitICmpInst(ICmpInst &ICI);
189  bool visitFCmpInst(FCmpInst &FCI);
190  bool visitUnaryOperator(UnaryOperator &UO);
191  bool visitBinaryOperator(BinaryOperator &BO);
192  bool visitGetElementPtrInst(GetElementPtrInst &GEPI);
193  bool visitCastInst(CastInst &CI);
194  bool visitBitCastInst(BitCastInst &BCI);
195  bool visitShuffleVectorInst(ShuffleVectorInst &SVI);
196  bool visitPHINode(PHINode &PHI);
197  bool visitLoadInst(LoadInst &LI);
198  bool visitStoreInst(StoreInst &SI);
199  bool visitCallInst(CallInst &ICI);
200 
201 private:
202  Scatterer scatter(Instruction *Point, Value *V);
203  void gather(Instruction *Op, const ValueVector &CV);
204  bool canTransferMetadata(unsigned Kind);
205  void transferMetadataAndIRFlags(Instruction *Op, const ValueVector &CV);
206  bool getVectorLayout(Type *Ty, unsigned Alignment, VectorLayout &Layout,
207  const DataLayout &DL);
208  bool finish();
209 
210  template<typename T> bool splitUnary(Instruction &, const T &);
211  template<typename T> bool splitBinary(Instruction &, const T &);
212 
213  bool splitCall(CallInst &CI);
214 
215  ScatterMap Scattered;
216  GatherList Gathered;
217 
218  unsigned ParallelLoopAccessMDKind;
219 
220  DominatorTree *DT;
221 };
222 
223 class ScalarizerLegacyPass : public FunctionPass {
224 public:
225  static char ID;
226 
227  ScalarizerLegacyPass() : FunctionPass(ID) {
229  }
230 
231  bool runOnFunction(Function &F) override;
232 
233  void getAnalysisUsage(AnalysisUsage& AU) const override {
236  }
237 };
238 
239 } // end anonymous namespace
240 
241 char ScalarizerLegacyPass::ID = 0;
242 INITIALIZE_PASS_BEGIN(ScalarizerLegacyPass, "scalarizer",
243  "Scalarize vector operations", false, false)
245 INITIALIZE_PASS_END(ScalarizerLegacyPass, "scalarizer",
246  "Scalarize vector operations", false, false)
247 
248 Scatterer::Scatterer(BasicBlock *bb, BasicBlock::iterator bbi, Value *v,
249  ValueVector *cachePtr)
250  : BB(bb), BBI(bbi), V(v), CachePtr(cachePtr) {
251  Type *Ty = V->getType();
252  PtrTy = dyn_cast<PointerType>(Ty);
253  if (PtrTy)
254  Ty = PtrTy->getElementType();
255  Size = Ty->getVectorNumElements();
256  if (!CachePtr)
257  Tmp.resize(Size, nullptr);
258  else if (CachePtr->empty())
259  CachePtr->resize(Size, nullptr);
260  else
261  assert(Size == CachePtr->size() && "Inconsistent vector sizes");
262 }
263 
264 // Return component I, creating a new Value for it if necessary.
265 Value *Scatterer::operator[](unsigned I) {
266  ValueVector &CV = (CachePtr ? *CachePtr : Tmp);
267  // Try to reuse a previous value.
268  if (CV[I])
269  return CV[I];
270  IRBuilder<> Builder(BB, BBI);
271  if (PtrTy) {
272  Type *ElTy = PtrTy->getElementType()->getVectorElementType();
273  if (!CV[0]) {
274  Type *NewPtrTy = PointerType::get(ElTy, PtrTy->getAddressSpace());
275  CV[0] = Builder.CreateBitCast(V, NewPtrTy, V->getName() + ".i0");
276  }
277  if (I != 0)
278  CV[I] = Builder.CreateConstGEP1_32(ElTy, CV[0], I,
279  V->getName() + ".i" + Twine(I));
280  } else {
281  // Search through a chain of InsertElementInsts looking for element I.
282  // Record other elements in the cache. The new V is still suitable
283  // for all uncached indices.
284  while (true) {
286  if (!Insert)
287  break;
288  ConstantInt *Idx = dyn_cast<ConstantInt>(Insert->getOperand(2));
289  if (!Idx)
290  break;
291  unsigned J = Idx->getZExtValue();
292  V = Insert->getOperand(0);
293  if (I == J) {
294  CV[J] = Insert->getOperand(1);
295  return CV[J];
296  } else if (!CV[J]) {
297  // Only cache the first entry we find for each index we're not actively
298  // searching for. This prevents us from going too far up the chain and
299  // caching incorrect entries.
300  CV[J] = Insert->getOperand(1);
301  }
302  }
303  CV[I] = Builder.CreateExtractElement(V, Builder.getInt32(I),
304  V->getName() + ".i" + Twine(I));
305  }
306  return CV[I];
307 }
308 
310  if (skipFunction(F))
311  return false;
312 
313  Module &M = *F.getParent();
314  unsigned ParallelLoopAccessMDKind =
315  M.getContext().getMDKindID("llvm.mem.parallel_loop_access");
316  DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
317  ScalarizerVisitor Impl(ParallelLoopAccessMDKind, DT);
318  return Impl.visit(F);
319 }
320 
322  return new ScalarizerLegacyPass();
323 }
324 
325 bool ScalarizerVisitor::visit(Function &F) {
326  assert(Gathered.empty() && Scattered.empty());
327 
328  // To ensure we replace gathered components correctly we need to do an ordered
329  // traversal of the basic blocks in the function.
331  for (BasicBlock *BB : RPOT) {
332  for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;) {
333  Instruction *I = &*II;
334  bool Done = InstVisitor::visit(I);
335  ++II;
336  if (Done && I->getType()->isVoidTy())
337  I->eraseFromParent();
338  }
339  }
340  return finish();
341 }
342 
343 // Return a scattered form of V that can be accessed by Point. V must be a
344 // vector or a pointer to a vector.
345 Scatterer ScalarizerVisitor::scatter(Instruction *Point, Value *V) {
346  if (Argument *VArg = dyn_cast<Argument>(V)) {
347  // Put the scattered form of arguments in the entry block,
348  // so that it can be used everywhere.
349  Function *F = VArg->getParent();
350  BasicBlock *BB = &F->getEntryBlock();
351  return Scatterer(BB, BB->begin(), V, &Scattered[V]);
352  }
353  if (Instruction *VOp = dyn_cast<Instruction>(V)) {
354  // When scalarizing PHI nodes we might try to examine/rewrite InsertElement
355  // nodes in predecessors. If those predecessors are unreachable from entry,
356  // then the IR in those blocks could have unexpected properties resulting in
357  // infinite loops in Scatterer::operator[]. By simply treating values
358  // originating from instructions in unreachable blocks as undef we do not
359  // need to analyse them further.
360  if (!DT->isReachableFromEntry(VOp->getParent()))
361  return Scatterer(Point->getParent(), Point->getIterator(),
362  UndefValue::get(V->getType()));
363  // Put the scattered form of an instruction directly after the
364  // instruction.
365  BasicBlock *BB = VOp->getParent();
366  return Scatterer(BB, std::next(BasicBlock::iterator(VOp)),
367  V, &Scattered[V]);
368  }
369  // In the fallback case, just put the scattered before Point and
370  // keep the result local to Point.
371  return Scatterer(Point->getParent(), Point->getIterator(), V);
372 }
373 
374 // Replace Op with the gathered form of the components in CV. Defer the
375 // deletion of Op and creation of the gathered form to the end of the pass,
376 // so that we can avoid creating the gathered form if all uses of Op are
377 // replaced with uses of CV.
378 void ScalarizerVisitor::gather(Instruction *Op, const ValueVector &CV) {
379  // Since we're not deleting Op yet, stub out its operands, so that it
380  // doesn't make anything live unnecessarily.
381  for (unsigned I = 0, E = Op->getNumOperands(); I != E; ++I)
382  Op->setOperand(I, UndefValue::get(Op->getOperand(I)->getType()));
383 
384  transferMetadataAndIRFlags(Op, CV);
385 
386  // If we already have a scattered form of Op (created from ExtractElements
387  // of Op itself), replace them with the new form.
388  ValueVector &SV = Scattered[Op];
389  if (!SV.empty()) {
390  for (unsigned I = 0, E = SV.size(); I != E; ++I) {
391  Value *V = SV[I];
392  if (V == nullptr)
393  continue;
394 
395  Instruction *Old = cast<Instruction>(V);
396  CV[I]->takeName(Old);
397  Old->replaceAllUsesWith(CV[I]);
398  Old->eraseFromParent();
399  }
400  }
401  SV = CV;
402  Gathered.push_back(GatherList::value_type(Op, &SV));
403 }
404 
405 // Return true if it is safe to transfer the given metadata tag from
406 // vector to scalar instructions.
407 bool ScalarizerVisitor::canTransferMetadata(unsigned Tag) {
408  return (Tag == LLVMContext::MD_tbaa
409  || Tag == LLVMContext::MD_fpmath
410  || Tag == LLVMContext::MD_tbaa_struct
411  || Tag == LLVMContext::MD_invariant_load
412  || Tag == LLVMContext::MD_alias_scope
413  || Tag == LLVMContext::MD_noalias
414  || Tag == ParallelLoopAccessMDKind
415  || Tag == LLVMContext::MD_access_group);
416 }
417 
418 // Transfer metadata from Op to the instructions in CV if it is known
419 // to be safe to do so.
420 void ScalarizerVisitor::transferMetadataAndIRFlags(Instruction *Op,
421  const ValueVector &CV) {
424  for (unsigned I = 0, E = CV.size(); I != E; ++I) {
425  if (Instruction *New = dyn_cast<Instruction>(CV[I])) {
426  for (const auto &MD : MDs)
427  if (canTransferMetadata(MD.first))
428  New->setMetadata(MD.first, MD.second);
429  New->copyIRFlags(Op);
430  if (Op->getDebugLoc() && !New->getDebugLoc())
431  New->setDebugLoc(Op->getDebugLoc());
432  }
433  }
434 }
435 
436 // Try to fill in Layout from Ty, returning true on success. Alignment is
437 // the alignment of the vector, or 0 if the ABI default should be used.
438 bool ScalarizerVisitor::getVectorLayout(Type *Ty, unsigned Alignment,
439  VectorLayout &Layout, const DataLayout &DL) {
440  // Make sure we're dealing with a vector.
441  Layout.VecTy = dyn_cast<VectorType>(Ty);
442  if (!Layout.VecTy)
443  return false;
444 
445  // Check that we're dealing with full-byte elements.
446  Layout.ElemTy = Layout.VecTy->getElementType();
447  if (!DL.typeSizeEqualsStoreSize(Layout.ElemTy))
448  return false;
449 
450  if (Alignment)
451  Layout.VecAlign = Alignment;
452  else
453  Layout.VecAlign = DL.getABITypeAlignment(Layout.VecTy);
454  Layout.ElemSize = DL.getTypeStoreSize(Layout.ElemTy);
455  return true;
456 }
457 
458 // Scalarize one-operand instruction I, using Split(Builder, X, Name)
459 // to create an instruction like I with operand X and name Name.
460 template<typename Splitter>
461 bool ScalarizerVisitor::splitUnary(Instruction &I, const Splitter &Split) {
463  if (!VT)
464  return false;
465 
466  unsigned NumElems = VT->getNumElements();
467  IRBuilder<> Builder(&I);
468  Scatterer Op = scatter(&I, I.getOperand(0));
469  assert(Op.size() == NumElems && "Mismatched unary operation");
470  ValueVector Res;
471  Res.resize(NumElems);
472  for (unsigned Elem = 0; Elem < NumElems; ++Elem)
473  Res[Elem] = Split(Builder, Op[Elem], I.getName() + ".i" + Twine(Elem));
474  gather(&I, Res);
475  return true;
476 }
477 
478 // Scalarize two-operand instruction I, using Split(Builder, X, Y, Name)
479 // to create an instruction like I with operands X and Y and name Name.
480 template<typename Splitter>
481 bool ScalarizerVisitor::splitBinary(Instruction &I, const Splitter &Split) {
483  if (!VT)
484  return false;
485 
486  unsigned NumElems = VT->getNumElements();
487  IRBuilder<> Builder(&I);
488  Scatterer Op0 = scatter(&I, I.getOperand(0));
489  Scatterer Op1 = scatter(&I, I.getOperand(1));
490  assert(Op0.size() == NumElems && "Mismatched binary operation");
491  assert(Op1.size() == NumElems && "Mismatched binary operation");
492  ValueVector Res;
493  Res.resize(NumElems);
494  for (unsigned Elem = 0; Elem < NumElems; ++Elem)
495  Res[Elem] = Split(Builder, Op0[Elem], Op1[Elem],
496  I.getName() + ".i" + Twine(Elem));
497  gather(&I, Res);
498  return true;
499 }
500 
502  return isTriviallyVectorizable(ID);
503 }
504 
505 // All of the current scalarizable intrinsics only have one mangled type.
508  VectorType *Ty) {
509  return Intrinsic::getDeclaration(M, ID, { Ty->getScalarType() });
510 }
511 
512 /// If a call to a vector typed intrinsic function, split into a scalar call per
513 /// element if possible for the intrinsic.
514 bool ScalarizerVisitor::splitCall(CallInst &CI) {
515  VectorType *VT = dyn_cast<VectorType>(CI.getType());
516  if (!VT)
517  return false;
518 
519  Function *F = CI.getCalledFunction();
520  if (!F)
521  return false;
522 
525  return false;
526 
527  unsigned NumElems = VT->getNumElements();
528  unsigned NumArgs = CI.getNumArgOperands();
529 
530  ValueVector ScalarOperands(NumArgs);
531  SmallVector<Scatterer, 8> Scattered(NumArgs);
532 
533  Scattered.resize(NumArgs);
534 
535  // Assumes that any vector type has the same number of elements as the return
536  // vector type, which is true for all current intrinsics.
537  for (unsigned I = 0; I != NumArgs; ++I) {
538  Value *OpI = CI.getOperand(I);
539  if (OpI->getType()->isVectorTy()) {
540  Scattered[I] = scatter(&CI, OpI);
541  assert(Scattered[I].size() == NumElems && "mismatched call operands");
542  } else {
543  ScalarOperands[I] = OpI;
544  }
545  }
546 
547  ValueVector Res(NumElems);
548  ValueVector ScalarCallOps(NumArgs);
549 
550  Function *NewIntrin = getScalarIntrinsicDeclaration(F->getParent(), ID, VT);
551  IRBuilder<> Builder(&CI);
552 
553  // Perform actual scalarization, taking care to preserve any scalar operands.
554  for (unsigned Elem = 0; Elem < NumElems; ++Elem) {
555  ScalarCallOps.clear();
556 
557  for (unsigned J = 0; J != NumArgs; ++J) {
558  if (hasVectorInstrinsicScalarOpd(ID, J))
559  ScalarCallOps.push_back(ScalarOperands[J]);
560  else
561  ScalarCallOps.push_back(Scattered[J][Elem]);
562  }
563 
564  Res[Elem] = Builder.CreateCall(NewIntrin, ScalarCallOps,
565  CI.getName() + ".i" + Twine(Elem));
566  }
567 
568  gather(&CI, Res);
569  return true;
570 }
571 
572 bool ScalarizerVisitor::visitSelectInst(SelectInst &SI) {
573  VectorType *VT = dyn_cast<VectorType>(SI.getType());
574  if (!VT)
575  return false;
576 
577  unsigned NumElems = VT->getNumElements();
578  IRBuilder<> Builder(&SI);
579  Scatterer Op1 = scatter(&SI, SI.getOperand(1));
580  Scatterer Op2 = scatter(&SI, SI.getOperand(2));
581  assert(Op1.size() == NumElems && "Mismatched select");
582  assert(Op2.size() == NumElems && "Mismatched select");
583  ValueVector Res;
584  Res.resize(NumElems);
585 
586  if (SI.getOperand(0)->getType()->isVectorTy()) {
587  Scatterer Op0 = scatter(&SI, SI.getOperand(0));
588  assert(Op0.size() == NumElems && "Mismatched select");
589  for (unsigned I = 0; I < NumElems; ++I)
590  Res[I] = Builder.CreateSelect(Op0[I], Op1[I], Op2[I],
591  SI.getName() + ".i" + Twine(I));
592  } else {
593  Value *Op0 = SI.getOperand(0);
594  for (unsigned I = 0; I < NumElems; ++I)
595  Res[I] = Builder.CreateSelect(Op0, Op1[I], Op2[I],
596  SI.getName() + ".i" + Twine(I));
597  }
598  gather(&SI, Res);
599  return true;
600 }
601 
602 bool ScalarizerVisitor::visitICmpInst(ICmpInst &ICI) {
603  return splitBinary(ICI, ICmpSplitter(ICI));
604 }
605 
606 bool ScalarizerVisitor::visitFCmpInst(FCmpInst &FCI) {
607  return splitBinary(FCI, FCmpSplitter(FCI));
608 }
609 
610 bool ScalarizerVisitor::visitUnaryOperator(UnaryOperator &UO) {
611  return splitUnary(UO, UnarySplitter(UO));
612 }
613 
614 bool ScalarizerVisitor::visitBinaryOperator(BinaryOperator &BO) {
615  return splitBinary(BO, BinarySplitter(BO));
616 }
617 
618 bool ScalarizerVisitor::visitGetElementPtrInst(GetElementPtrInst &GEPI) {
619  VectorType *VT = dyn_cast<VectorType>(GEPI.getType());
620  if (!VT)
621  return false;
622 
623  IRBuilder<> Builder(&GEPI);
624  unsigned NumElems = VT->getNumElements();
625  unsigned NumIndices = GEPI.getNumIndices();
626 
627  // The base pointer might be scalar even if it's a vector GEP. In those cases,
628  // splat the pointer into a vector value, and scatter that vector.
629  Value *Op0 = GEPI.getOperand(0);
630  if (!Op0->getType()->isVectorTy())
631  Op0 = Builder.CreateVectorSplat(NumElems, Op0);
632  Scatterer Base = scatter(&GEPI, Op0);
633 
635  Ops.resize(NumIndices);
636  for (unsigned I = 0; I < NumIndices; ++I) {
637  Value *Op = GEPI.getOperand(I + 1);
638 
639  // The indices might be scalars even if it's a vector GEP. In those cases,
640  // splat the scalar into a vector value, and scatter that vector.
641  if (!Op->getType()->isVectorTy())
642  Op = Builder.CreateVectorSplat(NumElems, Op);
643 
644  Ops[I] = scatter(&GEPI, Op);
645  }
646 
647  ValueVector Res;
648  Res.resize(NumElems);
649  for (unsigned I = 0; I < NumElems; ++I) {
650  SmallVector<Value *, 8> Indices;
651  Indices.resize(NumIndices);
652  for (unsigned J = 0; J < NumIndices; ++J)
653  Indices[J] = Ops[J][I];
654  Res[I] = Builder.CreateGEP(GEPI.getSourceElementType(), Base[I], Indices,
655  GEPI.getName() + ".i" + Twine(I));
656  if (GEPI.isInBounds())
657  if (GetElementPtrInst *NewGEPI = dyn_cast<GetElementPtrInst>(Res[I]))
658  NewGEPI->setIsInBounds();
659  }
660  gather(&GEPI, Res);
661  return true;
662 }
663 
664 bool ScalarizerVisitor::visitCastInst(CastInst &CI) {
666  if (!VT)
667  return false;
668 
669  unsigned NumElems = VT->getNumElements();
670  IRBuilder<> Builder(&CI);
671  Scatterer Op0 = scatter(&CI, CI.getOperand(0));
672  assert(Op0.size() == NumElems && "Mismatched cast");
673  ValueVector Res;
674  Res.resize(NumElems);
675  for (unsigned I = 0; I < NumElems; ++I)
676  Res[I] = Builder.CreateCast(CI.getOpcode(), Op0[I], VT->getElementType(),
677  CI.getName() + ".i" + Twine(I));
678  gather(&CI, Res);
679  return true;
680 }
681 
682 bool ScalarizerVisitor::visitBitCastInst(BitCastInst &BCI) {
683  VectorType *DstVT = dyn_cast<VectorType>(BCI.getDestTy());
684  VectorType *SrcVT = dyn_cast<VectorType>(BCI.getSrcTy());
685  if (!DstVT || !SrcVT)
686  return false;
687 
688  unsigned DstNumElems = DstVT->getNumElements();
689  unsigned SrcNumElems = SrcVT->getNumElements();
690  IRBuilder<> Builder(&BCI);
691  Scatterer Op0 = scatter(&BCI, BCI.getOperand(0));
692  ValueVector Res;
693  Res.resize(DstNumElems);
694 
695  if (DstNumElems == SrcNumElems) {
696  for (unsigned I = 0; I < DstNumElems; ++I)
697  Res[I] = Builder.CreateBitCast(Op0[I], DstVT->getElementType(),
698  BCI.getName() + ".i" + Twine(I));
699  } else if (DstNumElems > SrcNumElems) {
700  // <M x t1> -> <N*M x t2>. Convert each t1 to <N x t2> and copy the
701  // individual elements to the destination.
702  unsigned FanOut = DstNumElems / SrcNumElems;
703  Type *MidTy = VectorType::get(DstVT->getElementType(), FanOut);
704  unsigned ResI = 0;
705  for (unsigned Op0I = 0; Op0I < SrcNumElems; ++Op0I) {
706  Value *V = Op0[Op0I];
707  Instruction *VI;
708  // Look through any existing bitcasts before converting to <N x t2>.
709  // In the best case, the resulting conversion might be a no-op.
710  while ((VI = dyn_cast<Instruction>(V)) &&
711  VI->getOpcode() == Instruction::BitCast)
712  V = VI->getOperand(0);
713  V = Builder.CreateBitCast(V, MidTy, V->getName() + ".cast");
714  Scatterer Mid = scatter(&BCI, V);
715  for (unsigned MidI = 0; MidI < FanOut; ++MidI)
716  Res[ResI++] = Mid[MidI];
717  }
718  } else {
719  // <N*M x t1> -> <M x t2>. Convert each group of <N x t1> into a t2.
720  unsigned FanIn = SrcNumElems / DstNumElems;
721  Type *MidTy = VectorType::get(SrcVT->getElementType(), FanIn);
722  unsigned Op0I = 0;
723  for (unsigned ResI = 0; ResI < DstNumElems; ++ResI) {
724  Value *V = UndefValue::get(MidTy);
725  for (unsigned MidI = 0; MidI < FanIn; ++MidI)
726  V = Builder.CreateInsertElement(V, Op0[Op0I++], Builder.getInt32(MidI),
727  BCI.getName() + ".i" + Twine(ResI)
728  + ".upto" + Twine(MidI));
729  Res[ResI] = Builder.CreateBitCast(V, DstVT->getElementType(),
730  BCI.getName() + ".i" + Twine(ResI));
731  }
732  }
733  gather(&BCI, Res);
734  return true;
735 }
736 
737 bool ScalarizerVisitor::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
738  VectorType *VT = dyn_cast<VectorType>(SVI.getType());
739  if (!VT)
740  return false;
741 
742  unsigned NumElems = VT->getNumElements();
743  Scatterer Op0 = scatter(&SVI, SVI.getOperand(0));
744  Scatterer Op1 = scatter(&SVI, SVI.getOperand(1));
745  ValueVector Res;
746  Res.resize(NumElems);
747 
748  for (unsigned I = 0; I < NumElems; ++I) {
749  int Selector = SVI.getMaskValue(I);
750  if (Selector < 0)
751  Res[I] = UndefValue::get(VT->getElementType());
752  else if (unsigned(Selector) < Op0.size())
753  Res[I] = Op0[Selector];
754  else
755  Res[I] = Op1[Selector - Op0.size()];
756  }
757  gather(&SVI, Res);
758  return true;
759 }
760 
761 bool ScalarizerVisitor::visitPHINode(PHINode &PHI) {
762  VectorType *VT = dyn_cast<VectorType>(PHI.getType());
763  if (!VT)
764  return false;
765 
766  unsigned NumElems = VT->getNumElements();
767  IRBuilder<> Builder(&PHI);
768  ValueVector Res;
769  Res.resize(NumElems);
770 
771  unsigned NumOps = PHI.getNumOperands();
772  for (unsigned I = 0; I < NumElems; ++I)
773  Res[I] = Builder.CreatePHI(VT->getElementType(), NumOps,
774  PHI.getName() + ".i" + Twine(I));
775 
776  for (unsigned I = 0; I < NumOps; ++I) {
777  Scatterer Op = scatter(&PHI, PHI.getIncomingValue(I));
778  BasicBlock *IncomingBlock = PHI.getIncomingBlock(I);
779  for (unsigned J = 0; J < NumElems; ++J)
780  cast<PHINode>(Res[J])->addIncoming(Op[J], IncomingBlock);
781  }
782  gather(&PHI, Res);
783  return true;
784 }
785 
786 bool ScalarizerVisitor::visitLoadInst(LoadInst &LI) {
787  if (!ScalarizeLoadStore)
788  return false;
789  if (!LI.isSimple())
790  return false;
791 
792  VectorLayout Layout;
793  if (!getVectorLayout(LI.getType(), LI.getAlignment(), Layout,
794  LI.getModule()->getDataLayout()))
795  return false;
796 
797  unsigned NumElems = Layout.VecTy->getNumElements();
798  IRBuilder<> Builder(&LI);
799  Scatterer Ptr = scatter(&LI, LI.getPointerOperand());
800  ValueVector Res;
801  Res.resize(NumElems);
802 
803  for (unsigned I = 0; I < NumElems; ++I)
804  Res[I] = Builder.CreateAlignedLoad(Layout.VecTy->getElementType(), Ptr[I],
805  Layout.getElemAlign(I),
806  LI.getName() + ".i" + Twine(I));
807  gather(&LI, Res);
808  return true;
809 }
810 
811 bool ScalarizerVisitor::visitStoreInst(StoreInst &SI) {
812  if (!ScalarizeLoadStore)
813  return false;
814  if (!SI.isSimple())
815  return false;
816 
817  VectorLayout Layout;
818  Value *FullValue = SI.getValueOperand();
819  if (!getVectorLayout(FullValue->getType(), SI.getAlignment(), Layout,
820  SI.getModule()->getDataLayout()))
821  return false;
822 
823  unsigned NumElems = Layout.VecTy->getNumElements();
824  IRBuilder<> Builder(&SI);
825  Scatterer Ptr = scatter(&SI, SI.getPointerOperand());
826  Scatterer Val = scatter(&SI, FullValue);
827 
828  ValueVector Stores;
829  Stores.resize(NumElems);
830  for (unsigned I = 0; I < NumElems; ++I) {
831  unsigned Align = Layout.getElemAlign(I);
832  Stores[I] = Builder.CreateAlignedStore(Val[I], Ptr[I], Align);
833  }
834  transferMetadataAndIRFlags(&SI, Stores);
835  return true;
836 }
837 
838 bool ScalarizerVisitor::visitCallInst(CallInst &CI) {
839  return splitCall(CI);
840 }
841 
842 // Delete the instructions that we scalarized. If a full vector result
843 // is still needed, recreate it using InsertElements.
844 bool ScalarizerVisitor::finish() {
845  // The presence of data in Gathered or Scattered indicates changes
846  // made to the Function.
847  if (Gathered.empty() && Scattered.empty())
848  return false;
849  for (const auto &GMI : Gathered) {
850  Instruction *Op = GMI.first;
851  ValueVector &CV = *GMI.second;
852  if (!Op->use_empty()) {
853  // The value is still needed, so recreate it using a series of
854  // InsertElements.
855  Type *Ty = Op->getType();
856  Value *Res = UndefValue::get(Ty);
857  BasicBlock *BB = Op->getParent();
858  unsigned Count = Ty->getVectorNumElements();
859  IRBuilder<> Builder(Op);
860  if (isa<PHINode>(Op))
861  Builder.SetInsertPoint(BB, BB->getFirstInsertionPt());
862  for (unsigned I = 0; I < Count; ++I)
863  Res = Builder.CreateInsertElement(Res, CV[I], Builder.getInt32(I),
864  Op->getName() + ".upto" + Twine(I));
865  Res->takeName(Op);
866  Op->replaceAllUsesWith(Res);
867  }
868  Op->eraseFromParent();
869  }
870  Gathered.clear();
871  Scattered.clear();
872  return true;
873 }
874 
876  Module &M = *F.getParent();
877  unsigned ParallelLoopAccessMDKind =
878  M.getContext().getMDKindID("llvm.mem.parallel_loop_access");
880  ScalarizerVisitor Impl(ParallelLoopAccessMDKind, DT);
881  bool Changed = Impl.visit(F);
884  return Changed ? PA : PreservedAnalyses::all();
885 }
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode *>> &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
Definition: Instruction.h:267
Type * getVectorElementType() const
Definition: Type.h:376
Value * getValueOperand()
Definition: Instructions.h:426
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks &#39;this&#39; from the containing basic block and deletes it.
Definition: Instruction.cpp:67
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2356
bool isSimple() const
Definition: Instructions.h:287
Value * CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const Twine &Name="")
Definition: IRBuilder.h:1866
Type * getSrcTy() const
Return the source type, as a convenience.
Definition: InstrTypes.h:697
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1551
This class represents an incoming formal argument to a Function.
Definition: Argument.h:29
Base class for instruction visitors.
Definition: InstVisitor.h:80
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:777
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, unsigned Align, const char *Name)
Provided to resolve &#39;CreateAlignedLoad(Ptr, Align, "...")&#39; correctly, instead of converting the strin...
Definition: IRBuilder.h:1707
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
This class represents a function call, abstracting a target machine&#39;s calling convention.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
Definition: Type.cpp:637
This instruction constructs a fixed permutation of two input vectors.
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:230
F(f)
An instruction for reading from memory.
Definition: Instructions.h:169
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:230
bool typeSizeEqualsStoreSize(Type *Ty) const
Returns true if no extra padding bits are needed when storing the specified type. ...
Definition: DataLayout.h:474
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
Definition: IRBuilder.h:1777
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:273
unsigned getMDKindID(StringRef Name) const
getMDKindID - Return a unique non-zero ID for the specified metadata kind.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:50
INITIALIZE_PASS_BEGIN(ScalarizerLegacyPass, "scalarizer", "Scalarize vector operations", false, false) INITIALIZE_PASS_END(ScalarizerLegacyPass
void initializeScalarizerLegacyPassPass(PassRegistry &)
This class represents the LLVM &#39;select&#39; instruction.
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:369
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:439
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:245
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
Definition: DerivedTypes.h:398
Type * getSourceElementType() const
Definition: Instructions.h:989
void visit(Iterator Start, Iterator End)
Definition: InstVisitor.h:89
unsigned getNumIndices() const
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2101
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
Definition: InstrTypes.h:692
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:246
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Definition: DataLayout.h:454
This instruction compares its operands according to the predicate given to the constructor.
This class represents a no-op cast from one type to another.
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Definition: IRBuilder.h:2679
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:125
An instruction for storing to memory.
Definition: Instructions.h:331
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:430
void takeName(Value *V)
Transfer the name from V to this value.
Definition: Value.cpp:292
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:144
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:1112
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Definition: IRBuilder.h:132
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: Scalarizer.cpp:875
Value * getOperand(unsigned i) const
Definition: User.h:169
Class to represent pointers.
Definition: DerivedTypes.h:579
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return &#39;this&#39;.
Definition: Type.h:307
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:2367
bool isVoidTy() const
Return true if this is &#39;void&#39;.
Definition: Type.h:141
const BasicBlock & getEntryBlock() const
Definition: Function.h:675
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
Definition: MathExtras.h:661
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
Definition: Instructions.h:892
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:435
This instruction inserts a single (scalar) element into a VectorType value.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
Definition: Constants.h:148
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
Definition: BasicBlock.cpp:223
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
static Function * getScalarIntrinsicDeclaration(Module *M, Intrinsic::ID ID, VectorType *Ty)
Definition: Scalarizer.cpp:506
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
scalarizer
Definition: Scalarizer.cpp:245
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Definition: IRBuilder.h:2498
static bool isTriviallyScalariable(Intrinsic::ID ID)
Definition: Scalarizer.cpp:501
Represent the analysis usage information of a pass.
This instruction compares its operands according to the predicate given to the constructor.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:282
Scalarize vector operations
Definition: Scalarizer.cpp:245
Value * getPointerOperand()
Definition: Instructions.h:295
self_iterator getIterator()
Definition: ilist_node.h:81
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2520
static UndefValue * get(Type *T)
Static factory methods - Return an &#39;undef&#39; object of the specified type.
Definition: Constants.cpp:1514
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:160
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
static int getMaskValue(const Constant *Mask, unsigned Elt)
Return the shuffle mask value for the specified element of the mask.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Definition: IRBuilder.h:2411
Value * CreateGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Definition: IRBuilder.h:1808
Iterator for intrusive lists based on ilist_node.
unsigned getNumOperands() const
Definition: User.h:191
This is the shared class of boolean and integer constants.
Definition: Constants.h:83
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
Definition: STLExtras.h:1163
Module.h This file contains the declarations for the Module class.
Value * CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2533
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Definition: DataLayout.cpp:755
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:355
Type * getDestTy() const
Return the destination type, as a convenience.
Definition: InstrTypes.h:699
bool hasVectorInstrinsicScalarOpd(Intrinsic::ID ID, unsigned ScalarOpdIdx)
Identifies if the vector form of the intrinsic has a scalar operand.
Definition: VectorUtils.cpp:93
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:193
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
unsigned getVectorNumElements() const
Definition: DerivedTypes.h:566
This pass converts vector operations into scalar operations, in order to expose optimization opportun...
Class to represent vector types.
Definition: DerivedTypes.h:432
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:55
void push_back(pointer val)
Definition: ilist.h:311
static cl::opt< bool > ScalarizeLoadStore("scalarize-load-store", cl::init(false), cl::Hidden, cl::desc("Allow the scalarizer pass to scalarize loads and store"))
unsigned getNumArgOperands() const
Definition: InstrTypes.h:1244
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:331
unsigned getAlignment() const
Return the alignment of the access that is being performed.
Definition: Instructions.h:244
void clear()
Definition: ilist.h:307
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:614
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:215
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
Definition: InstrTypes.h:1305
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:106
#define I(x, y, z)
Definition: MD5.cpp:58
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:332
uint32_t Size
Definition: Profile.cpp:46
void preserve()
Mark an analysis as preserved.
Definition: PassManager.h:175
unsigned getAlignment() const
Return the alignment of the access that is being performed FIXME: Remove this function once transitio...
Definition: Instructions.h:376
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
Definition: IRBuilder.h:2138
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1623
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:575
LLVM Value Representation.
Definition: Value.h:74
Type * getElementType() const
Definition: DerivedTypes.h:399
FunctionPass * createScalarizerPass()
Create a legacy pass manager instance of the Scalarizer pass.
Definition: Scalarizer.cpp:321
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:259
bool isSimple() const
Definition: Instructions.h:418
VectorType * getType() const
Overload to return most specific vector type.
Value * getPointerOperand()
Definition: Instructions.h:429
bool use_empty() const
Definition: Value.h:343
const BasicBlock * getParent() const
Definition: Instruction.h:66
bool isTriviallyVectorizable(Intrinsic::ID ID)
Identify if the intrinsic is trivially vectorizable.
Definition: VectorUtils.cpp:44
void resize(size_type N)
Definition: SmallVector.h:344