LLVM  13.0.0git
ExpandVectorPredication.cpp
Go to the documentation of this file.
1 //===----- CodeGen/ExpandVectorPredication.cpp - Expand VP intrinsics -----===//
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 implements IR expansion for vector predication intrinsics, allowing
10 // targets to enable vector predication until just before codegen.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/Statistic.h"
18 #include "llvm/CodeGen/Passes.h"
19 #include "llvm/IR/Constants.h"
20 #include "llvm/IR/Function.h"
21 #include "llvm/IR/IRBuilder.h"
22 #include "llvm/IR/InstIterator.h"
23 #include "llvm/IR/Instructions.h"
24 #include "llvm/IR/IntrinsicInst.h"
25 #include "llvm/IR/Intrinsics.h"
26 #include "llvm/IR/Module.h"
27 #include "llvm/InitializePasses.h"
28 #include "llvm/Pass.h"
30 #include "llvm/Support/Compiler.h"
31 #include "llvm/Support/Debug.h"
33 
34 using namespace llvm;
35 
38 
39 // Keep this in sync with TargetTransformInfo::VPLegalization.
40 #define VPINTERNAL_VPLEGAL_CASES \
41  VPINTERNAL_CASE(Legal) \
42  VPINTERNAL_CASE(Discard) \
43  VPINTERNAL_CASE(Convert)
44 
45 #define VPINTERNAL_CASE(X) "|" #X
46 
47 // Override options.
49  "expandvp-override-evl-transform", cl::init(""), cl::Hidden,
50  cl::desc("Options: <empty>" VPINTERNAL_VPLEGAL_CASES
51  ". If non-empty, ignore "
52  "TargetTransformInfo and "
53  "always use this transformation for the %evl parameter (Used in "
54  "testing)."));
55 
57  "expandvp-override-mask-transform", cl::init(""), cl::Hidden,
58  cl::desc("Options: <empty>" VPINTERNAL_VPLEGAL_CASES
59  ". If non-empty, Ignore "
60  "TargetTransformInfo and "
61  "always use this transformation for the %mask parameter (Used in "
62  "testing)."));
63 
64 #undef VPINTERNAL_CASE
65 #define VPINTERNAL_CASE(X) .Case(#X, VPLegalization::X)
66 
67 static VPTransform parseOverrideOption(const std::string &TextOpt) {
69 }
70 
71 #undef VPINTERNAL_VPLEGAL_CASES
72 
73 // Whether any override options are set.
74 static bool anyExpandVPOverridesSet() {
75  return !EVLTransformOverride.empty() || !MaskTransformOverride.empty();
76 }
77 
78 #define DEBUG_TYPE "expandvp"
79 
80 STATISTIC(NumFoldedVL, "Number of folded vector length params");
81 STATISTIC(NumLoweredVPOps, "Number of folded vector predication operations");
82 
83 ///// Helpers {
84 
85 /// \returns Whether the vector mask \p MaskVal has all lane bits set.
86 static bool isAllTrueMask(Value *MaskVal) {
87  auto *ConstVec = dyn_cast<ConstantVector>(MaskVal);
88  return ConstVec && ConstVec->isAllOnesValue();
89 }
90 
91 /// \returns A non-excepting divisor constant for this type.
92 static Constant *getSafeDivisor(Type *DivTy) {
93  assert(DivTy->isIntOrIntVectorTy() && "Unsupported divisor type");
94  return ConstantInt::get(DivTy, 1u, false);
95 }
96 
97 /// Transfer operation properties from \p OldVPI to \p NewVal.
98 static void transferDecorations(Value &NewVal, VPIntrinsic &VPI) {
99  auto *NewInst = dyn_cast<Instruction>(&NewVal);
100  if (!NewInst || !isa<FPMathOperator>(NewVal))
101  return;
102 
103  auto *OldFMOp = dyn_cast<FPMathOperator>(&VPI);
104  if (!OldFMOp)
105  return;
106 
107  NewInst->setFastMathFlags(OldFMOp->getFastMathFlags());
108 }
109 
110 /// Transfer all properties from \p OldOp to \p NewOp and replace all uses.
111 /// OldVP gets erased.
112 static void replaceOperation(Value &NewOp, VPIntrinsic &OldOp) {
113  transferDecorations(NewOp, OldOp);
114  OldOp.replaceAllUsesWith(&NewOp);
115  OldOp.eraseFromParent();
116 }
117 
118 //// } Helpers
119 
120 namespace {
121 
122 // Expansion pass state at function scope.
123 struct CachingVPExpander {
124  Function &F;
125  const TargetTransformInfo &TTI;
126 
127  /// \returns A (fixed length) vector with ascending integer indices
128  /// (<0, 1, ..., NumElems-1>).
129  /// \p Builder
130  /// Used for instruction creation.
131  /// \p LaneTy
132  /// Integer element type of the result vector.
133  /// \p NumElems
134  /// Number of vector elements.
135  Value *createStepVector(IRBuilder<> &Builder, Type *LaneTy,
136  unsigned NumElems);
137 
138  /// \returns A bitmask that is true where the lane position is less-than \p
139  /// EVLParam
140  ///
141  /// \p Builder
142  /// Used for instruction creation.
143  /// \p VLParam
144  /// The explicit vector length parameter to test against the lane
145  /// positions.
146  /// \p ElemCount
147  /// Static (potentially scalable) number of vector elements.
148  Value *convertEVLToMask(IRBuilder<> &Builder, Value *EVLParam,
149  ElementCount ElemCount);
150 
151  Value *foldEVLIntoMask(VPIntrinsic &VPI);
152 
153  /// "Remove" the %evl parameter of \p PI by setting it to the static vector
154  /// length of the operation.
155  void discardEVLParameter(VPIntrinsic &PI);
156 
157  /// \brief Lower this VP binary operator to a unpredicated binary operator.
158  Value *expandPredicationInBinaryOperator(IRBuilder<> &Builder,
159  VPIntrinsic &PI);
160 
161  /// \brief Query TTI and expand the vector predication in \p P accordingly.
162  Value *expandPredication(VPIntrinsic &PI);
163 
164  /// \brief Determine how and whether the VPIntrinsic \p VPI shall be
165  /// expanded. This overrides TTI with the cl::opts listed at the top of this
166  /// file.
167  VPLegalization getVPLegalizationStrategy(const VPIntrinsic &VPI) const;
168  bool UsingTTIOverrides;
169 
170 public:
171  CachingVPExpander(Function &F, const TargetTransformInfo &TTI)
172  : F(F), TTI(TTI), UsingTTIOverrides(anyExpandVPOverridesSet()) {}
173 
174  bool expandVectorPredication();
175 };
176 
177 //// CachingVPExpander {
178 
179 Value *CachingVPExpander::createStepVector(IRBuilder<> &Builder, Type *LaneTy,
180  unsigned NumElems) {
181  // TODO add caching
182  SmallVector<Constant *, 16> ConstElems;
183 
184  for (unsigned Idx = 0; Idx < NumElems; ++Idx)
185  ConstElems.push_back(ConstantInt::get(LaneTy, Idx, false));
186 
187  return ConstantVector::get(ConstElems);
188 }
189 
190 Value *CachingVPExpander::convertEVLToMask(IRBuilder<> &Builder,
191  Value *EVLParam,
192  ElementCount ElemCount) {
193  // TODO add caching
194  // Scalable vector %evl conversion.
195  if (ElemCount.isScalable()) {
196  auto *M = Builder.GetInsertBlock()->getModule();
197  Type *BoolVecTy = VectorType::get(Builder.getInt1Ty(), ElemCount);
198  Function *ActiveMaskFunc = Intrinsic::getDeclaration(
199  M, Intrinsic::get_active_lane_mask, {BoolVecTy, EVLParam->getType()});
200  // `get_active_lane_mask` performs an implicit less-than comparison.
201  Value *ConstZero = Builder.getInt32(0);
202  return Builder.CreateCall(ActiveMaskFunc, {ConstZero, EVLParam});
203  }
204 
205  // Fixed vector %evl conversion.
206  Type *LaneTy = EVLParam->getType();
207  unsigned NumElems = ElemCount.getFixedValue();
208  Value *VLSplat = Builder.CreateVectorSplat(NumElems, EVLParam);
209  Value *IdxVec = createStepVector(Builder, LaneTy, NumElems);
210  return Builder.CreateICmp(CmpInst::ICMP_ULT, IdxVec, VLSplat);
211 }
212 
213 Value *
214 CachingVPExpander::expandPredicationInBinaryOperator(IRBuilder<> &Builder,
215  VPIntrinsic &VPI) {
218  "Implicitly dropping %evl in non-speculatable operator!");
219 
220  auto OC = static_cast<Instruction::BinaryOps>(*VPI.getFunctionalOpcode());
222 
223  Value *Op0 = VPI.getOperand(0);
224  Value *Op1 = VPI.getOperand(1);
225  Value *Mask = VPI.getMaskParam();
226 
227  // Blend in safe operands.
228  if (Mask && !isAllTrueMask(Mask)) {
229  switch (OC) {
230  default:
231  // Can safely ignore the predicate.
232  break;
233 
234  // Division operators need a safe divisor on masked-off lanes (1).
235  case Instruction::UDiv:
236  case Instruction::SDiv:
237  case Instruction::URem:
238  case Instruction::SRem:
239  // 2nd operand must not be zero.
240  Value *SafeDivisor = getSafeDivisor(VPI.getType());
241  Op1 = Builder.CreateSelect(Mask, Op1, SafeDivisor);
242  }
243  }
244 
245  Value *NewBinOp = Builder.CreateBinOp(OC, Op0, Op1, VPI.getName());
246 
247  replaceOperation(*NewBinOp, VPI);
248  return NewBinOp;
249 }
250 
251 void CachingVPExpander::discardEVLParameter(VPIntrinsic &VPI) {
252  LLVM_DEBUG(dbgs() << "Discard EVL parameter in " << VPI << "\n");
253 
254  if (VPI.canIgnoreVectorLengthParam())
255  return;
256 
257  Value *EVLParam = VPI.getVectorLengthParam();
258  if (!EVLParam)
259  return;
260 
261  ElementCount StaticElemCount = VPI.getStaticVectorLength();
262  Value *MaxEVL = nullptr;
264  if (StaticElemCount.isScalable()) {
265  // TODO add caching
266  auto *M = VPI.getModule();
267  Function *VScaleFunc =
268  Intrinsic::getDeclaration(M, Intrinsic::vscale, Int32Ty);
270  Value *FactorConst = Builder.getInt32(StaticElemCount.getKnownMinValue());
271  Value *VScale = Builder.CreateCall(VScaleFunc, {}, "vscale");
272  MaxEVL = Builder.CreateMul(VScale, FactorConst, "scalable_size",
273  /*NUW*/ true, /*NSW*/ false);
274  } else {
275  MaxEVL = ConstantInt::get(Int32Ty, StaticElemCount.getFixedValue(), false);
276  }
277  VPI.setVectorLengthParam(MaxEVL);
278 }
279 
280 Value *CachingVPExpander::foldEVLIntoMask(VPIntrinsic &VPI) {
281  LLVM_DEBUG(dbgs() << "Folding vlen for " << VPI << '\n');
282 
283  IRBuilder<> Builder(&VPI);
284 
285  // Ineffective %evl parameter and so nothing to do here.
286  if (VPI.canIgnoreVectorLengthParam())
287  return &VPI;
288 
289  // Only VP intrinsics can have an %evl parameter.
290  Value *OldMaskParam = VPI.getMaskParam();
291  Value *OldEVLParam = VPI.getVectorLengthParam();
292  assert(OldMaskParam && "no mask param to fold the vl param into");
293  assert(OldEVLParam && "no EVL param to fold away");
294 
295  LLVM_DEBUG(dbgs() << "OLD evl: " << *OldEVLParam << '\n');
296  LLVM_DEBUG(dbgs() << "OLD mask: " << *OldMaskParam << '\n');
297 
298  // Convert the %evl predication into vector mask predication.
299  ElementCount ElemCount = VPI.getStaticVectorLength();
300  Value *VLMask = convertEVLToMask(Builder, OldEVLParam, ElemCount);
301  Value *NewMaskParam = Builder.CreateAnd(VLMask, OldMaskParam);
302  VPI.setMaskParam(NewMaskParam);
303 
304  // Drop the %evl parameter.
305  discardEVLParameter(VPI);
307  "transformation did not render the evl param ineffective!");
308 
309  // Reassess the modified instruction.
310  return &VPI;
311 }
312 
313 Value *CachingVPExpander::expandPredication(VPIntrinsic &VPI) {
314  LLVM_DEBUG(dbgs() << "Lowering to unpredicated op: " << VPI << '\n');
315 
316  IRBuilder<> Builder(&VPI);
317 
318  // Try lowering to a LLVM instruction first.
319  auto OC = VPI.getFunctionalOpcode();
320 
321  if (OC && Instruction::isBinaryOp(*OC))
322  return expandPredicationInBinaryOperator(Builder, VPI);
323 
324  return &VPI;
325 }
326 
327 //// } CachingVPExpander
328 
329 struct TransformJob {
330  VPIntrinsic *PI;
332  TransformJob(VPIntrinsic *PI, TargetTransformInfo::VPLegalization InitStrat)
333  : PI(PI), Strategy(InitStrat) {}
334 
335  bool isDone() const { return Strategy.shouldDoNothing(); }
336 };
337 
338 void sanitizeStrategy(Instruction &I, VPLegalization &LegalizeStrat) {
339  // Speculatable instructions do not strictly need predication.
341  // Converting a speculatable VP intrinsic means dropping %mask and %evl.
342  // No need to expand %evl into the %mask only to ignore that code.
343  if (LegalizeStrat.OpStrategy == VPLegalization::Convert)
345  return;
346  }
347 
348  // We have to preserve the predicating effect of %evl for this
349  // non-speculatable VP intrinsic.
350  // 1) Never discard %evl.
351  // 2) If this VP intrinsic will be expanded to non-VP code, make sure that
352  // %evl gets folded into %mask.
353  if ((LegalizeStrat.EVLParamStrategy == VPLegalization::Discard) ||
354  (LegalizeStrat.OpStrategy == VPLegalization::Convert)) {
356  }
357 }
358 
360 CachingVPExpander::getVPLegalizationStrategy(const VPIntrinsic &VPI) const {
361  auto VPStrat = TTI.getVPLegalizationStrategy(VPI);
362  if (LLVM_LIKELY(!UsingTTIOverrides)) {
363  // No overrides - we are in production.
364  return VPStrat;
365  }
366 
367  // Overrides set - we are in testing, the following does not need to be
368  // efficient.
370  VPStrat.OpStrategy = parseOverrideOption(MaskTransformOverride);
371  return VPStrat;
372 }
373 
374 /// \brief Expand llvm.vp.* intrinsics as requested by \p TTI.
375 bool CachingVPExpander::expandVectorPredication() {
377 
378  // Collect all VPIntrinsics that need expansion and determine their expansion
379  // strategy.
380  for (auto &I : instructions(F)) {
381  auto *VPI = dyn_cast<VPIntrinsic>(&I);
382  if (!VPI)
383  continue;
384  auto VPStrat = getVPLegalizationStrategy(*VPI);
385  sanitizeStrategy(I, VPStrat);
386  if (!VPStrat.shouldDoNothing())
387  Worklist.emplace_back(VPI, VPStrat);
388  }
389  if (Worklist.empty())
390  return false;
391 
392  // Transform all VPIntrinsics on the worklist.
393  LLVM_DEBUG(dbgs() << "\n:::: Transforming " << Worklist.size()
394  << " instructions ::::\n");
395  for (TransformJob Job : Worklist) {
396  // Transform the EVL parameter.
397  switch (Job.Strategy.EVLParamStrategy) {
399  break;
401  discardEVLParameter(*Job.PI);
402  break;
404  if (foldEVLIntoMask(*Job.PI))
405  ++NumFoldedVL;
406  break;
407  }
408  Job.Strategy.EVLParamStrategy = VPLegalization::Legal;
409 
410  // Replace with a non-predicated operation.
411  switch (Job.Strategy.OpStrategy) {
413  break;
415  llvm_unreachable("Invalid strategy for operators.");
417  expandPredication(*Job.PI);
418  ++NumLoweredVPOps;
419  break;
420  }
421  Job.Strategy.OpStrategy = VPLegalization::Legal;
422 
423  assert(Job.isDone() && "incomplete transformation");
424  }
425 
426  return true;
427 }
428 class ExpandVectorPredication : public FunctionPass {
429 public:
430  static char ID;
431  ExpandVectorPredication() : FunctionPass(ID) {
433  }
434 
435  bool runOnFunction(Function &F) override {
436  const auto *TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
437  CachingVPExpander VPExpander(F, *TTI);
438  return VPExpander.expandVectorPredication();
439  }
440 
441  void getAnalysisUsage(AnalysisUsage &AU) const override {
443  AU.setPreservesCFG();
444  }
445 };
446 } // namespace
447 
449 INITIALIZE_PASS_BEGIN(ExpandVectorPredication, "expandvp",
450  "Expand vector predication intrinsics", false, false)
453 INITIALIZE_PASS_END(ExpandVectorPredication, "expandvp",
454  "Expand vector predication intrinsics", false, false)
455 
457  return new ExpandVectorPredication();
458 }
459 
462  const auto &TTI = AM.getResult<TargetIRAnalysis>(F);
463  CachingVPExpander VPExpander(F, TTI);
464  if (!VPExpander.expandVectorPredication())
465  return PreservedAnalyses::all();
467  PA.preserveSet<CFGAnalyses>();
468  return PA;
469 }
transferDecorations
static void transferDecorations(Value &NewVal, VPIntrinsic &VPI)
Transfer operation properties from OldVPI to NewVal.
Definition: ExpandVectorPredication.cpp:98
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
Int32Ty
IntegerType * Int32Ty
Definition: NVVMIntrRange.cpp:67
llvm::TargetIRAnalysis
Analysis pass providing the TargetTransformInfo.
Definition: TargetTransformInfo.h:2320
llvm::initializeExpandVectorPredicationPass
void initializeExpandVectorPredicationPass(PassRegistry &)
MathExtras.h
llvm
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::Instruction::getModule
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:66
expandvp
expandvp
Definition: ExpandVectorPredication.cpp:453
llvm::Intrinsic::getDeclaration
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:1329
llvm::isSafeToSpeculativelyExecute
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
Return true if the instruction does not have any effects besides calculating the result and does not ...
Definition: ValueTracking.cpp:4541
IntrinsicInst.h
llvm::ElementCount
Definition: TypeSize.h:386
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:769
InstIterator.h
llvm::Function
Definition: Function.h:61
Pass.h
llvm::TargetTransformInfo::getVPLegalizationStrategy
VPLegalization getVPLegalizationStrategy(const VPIntrinsic &PI) const
Definition: TargetTransformInfo.cpp:1031
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1167
Statistic.h
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:167
llvm::VPIntrinsic::setVectorLengthParam
void setVectorLengthParam(Value *)
Definition: IntrinsicInst.cpp:313
llvm::IRBuilder<>
ValueTracking.h
llvm::VPIntrinsic::canIgnoreVectorLengthParam
bool canIgnoreVectorLengthParam() const
Definition: IntrinsicInst.cpp:382
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::TargetTransformInfo::VPLegalization
Definition: TargetTransformInfo.h:1383
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
Module.h
llvm::TargetTransformInfo::VPLegalization::Convert
@ Convert
Definition: TargetTransformInfo.h:1390
parseOverrideOption
static VPTransform parseOverrideOption(const std::string &TextOpt)
Definition: ExpandVectorPredication.cpp:67
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::LinearPolySize::isScalable
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:299
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:197
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:122
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::VPIntrinsic::setMaskParam
void setMaskParam(Value *)
Definition: IntrinsicInst.cpp:302
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
CommandLine.h
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
intrinsics
Expand vector predication intrinsics
Definition: ExpandVectorPredication.cpp:454
Constants.h
Intrinsics.h
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
false
Definition: StackSlotColoring.cpp:142
llvm::Instruction
Definition: Instruction.h:45
llvm::DominatorTreeWrapperPass
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:281
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::ConstantInt::get
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:898
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::VPIntrinsic::getVectorLengthParam
Value * getVectorLengthParam() const
Definition: IntrinsicInst.cpp:307
llvm::TargetTransformInfo::VPLegalization::EVLParamStrategy
VPTransform EVLParamStrategy
Definition: TargetTransformInfo.h:1397
Passes.h
llvm::VPIntrinsic::getFunctionalOpcode
Optional< unsigned > getFunctionalOpcode() const
Definition: IntrinsicInst.h:425
ExpandVectorPredication.h
llvm::TargetTransformInfo::VPLegalization::VPTransform
VPTransform
Definition: TargetTransformInfo.h:1384
llvm::cl::opt
Definition: CommandLine.h:1422
llvm::instructions
inst_range instructions(Function *F)
Definition: InstIterator.h:133
llvm::VPIntrinsic::getStaticVectorLength
ElementCount getStaticVectorLength() const
Definition: IntrinsicInst.cpp:284
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::Instruction::eraseFromParent
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition: Instruction.cpp:78
EVLTransformOverride
static cl::opt< std::string > EVLTransformOverride("expandvp-override-evl-transform", cl::init(""), cl::Hidden, cl::desc("Options: <empty>" VPINTERNAL_VPLEGAL_CASES ". If non-empty, ignore " "TargetTransformInfo and " "always use this transformation for the %evl parameter (Used in " "testing)."))
llvm::TargetTransformInfo::VPLegalization::OpStrategy
VPTransform OpStrategy
Definition: TargetTransformInfo.h:1403
llvm::TargetTransformInfoWrapperPass
Wrapper pass for TargetTransformInfo.
Definition: TargetTransformInfo.h:2376
replaceOperation
static void replaceOperation(Value &NewOp, VPIntrinsic &OldOp)
Transfer all properties from OldOp to NewOp and replace all uses.
Definition: ExpandVectorPredication.cpp:112
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::TargetTransformInfo::VPLegalization::shouldDoNothing
bool shouldDoNothing() const
Definition: TargetTransformInfo.h:1405
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
anyExpandVPOverridesSet
static bool anyExpandVPOverridesSet()
Definition: ExpandVectorPredication.cpp:74
IRBuilder.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetTransformInfo::VPLegalization::Discard
@ Discard
Definition: TargetTransformInfo.h:1388
llvm::SystemZISD::OC
@ OC
Definition: SystemZISelLowering.h:128
llvm::createExpandVectorPredicationPass
FunctionPass * createExpandVectorPredicationPass()
This pass expands the vector predication intrinsics into unpredicated instructions with selects or ju...
Definition: ExpandVectorPredication.cpp:456
llvm::TTI
TargetTransformInfo TTI
Definition: TargetTransformInfo.h:162
llvm::Instruction::isBinaryOp
bool isBinaryOp() const
Definition: Instruction.h:165
predication
loop predication
Definition: LoopPredication.cpp:351
llvm::LinearPolySize::getKnownMinValue
ScalarTy getKnownMinValue() const
Returns the minimum value this size can represent.
Definition: TypeSize.h:297
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::AnalysisUsage::setPreservesCFG
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:253
llvm::CmpInst::ICMP_ULT
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:747
llvm::LinearPolySize::getFixedValue
ScalarTy getFixedValue() const
Definition: TypeSize.h:313
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::CFGAnalyses
Represents analyses that only rely on functions' control flow.
Definition: PassManager.h:116
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:517
Compiler.h
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:965
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:81
llvm::ConstantVector::get
static Constant * get(ArrayRef< Constant * > V)
Definition: Constants.cpp:1367
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:294
MaskTransformOverride
static cl::opt< std::string > MaskTransformOverride("expandvp-override-mask-transform", cl::init(""), cl::Hidden, cl::desc("Options: <empty>" VPINTERNAL_VPLEGAL_CASES ". If non-empty, Ignore " "TargetTransformInfo and " "always use this transformation for the %mask parameter (Used in " "testing)."))
llvm::ExpandVectorPredicationPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: ExpandVectorPredication.cpp:461
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(ExpandVectorPredication, "expandvp", "Expand vector predication intrinsics", false, false) INITIALIZE_PASS_END(ExpandVectorPredication
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition: EntryExitInstrumenter.cpp:69
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:161
llvm::VPIntrinsic
This is the common base class for vector predication intrinsics.
Definition: IntrinsicInst.h:390
llvm::Type::isIntOrIntVectorTy
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition: Type.h:208
VPLegalization
TargetTransformInfo::VPLegalization VPLegalization
Definition: ExpandVectorPredication.cpp:36
Function.h
VPINTERNAL_VPLEGAL_CASES
#define VPINTERNAL_VPLEGAL_CASES
Definition: ExpandVectorPredication.cpp:40
llvm::Instruction::BinaryOps
BinaryOps
Definition: Instruction.h:773
Instructions.h
llvm::PreservedAnalyses::preserveSet
void preserveSet()
Mark an analysis set as preserved.
Definition: PassManager.h:191
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:94
llvm::TargetTransformInfo::VPLegalization::Legal
@ Legal
Definition: TargetTransformInfo.h:1386
getSafeDivisor
static Constant * getSafeDivisor(Type *DivTy)
Definition: ExpandVectorPredication.cpp:92
TargetTransformInfo.h
LLVM_LIKELY
#define LLVM_LIKELY(EXPR)
Definition: Compiler.h:219
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
llvm::VPIntrinsic::getMaskParam
Value * getMaskParam() const
Definition: IntrinsicInst.cpp:296
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::cl::desc
Definition: CommandLine.h:414
isAllTrueMask
static bool isAllTrueMask(Value *MaskVal)
Definition: ExpandVectorPredication.cpp:86
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
Debug.h
llvm::VectorType::get
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:628
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:907
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38