LLVM  14.0.0git
AlignmentFromAssumptions.cpp
Go to the documentation of this file.
1 //===----------------------- AlignmentFromAssumptions.cpp -----------------===//
2 // Set Load/Store Alignments From Assumptions
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements a ScalarEvolution-based transformation to set
11 // the alignments of load, stores and memory intrinsics based on the truth
12 // expressions of assume intrinsics. The primary motivation is to handle
13 // complex alignment assumptions that apply to vector loads and stores that
14 // appear after vectorization and unrolling.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #include "llvm/IR/Instructions.h"
19 #include "llvm/InitializePasses.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/Statistic.h"
26 #include "llvm/Analysis/LoopInfo.h"
29 #include "llvm/IR/Constant.h"
30 #include "llvm/IR/Dominators.h"
31 #include "llvm/IR/Instruction.h"
32 #include "llvm/IR/IntrinsicInst.h"
33 #include "llvm/IR/Intrinsics.h"
34 #include "llvm/IR/Module.h"
35 #include "llvm/Support/Debug.h"
37 #include "llvm/Transforms/Scalar.h"
38 
39 #define AA_NAME "alignment-from-assumptions"
40 #define DEBUG_TYPE AA_NAME
41 using namespace llvm;
42 
43 STATISTIC(NumLoadAlignChanged,
44  "Number of loads changed by alignment assumptions");
45 STATISTIC(NumStoreAlignChanged,
46  "Number of stores changed by alignment assumptions");
47 STATISTIC(NumMemIntAlignChanged,
48  "Number of memory intrinsics changed by alignment assumptions");
49 
50 namespace {
51 struct AlignmentFromAssumptions : public FunctionPass {
52  static char ID; // Pass identification, replacement for typeid
53  AlignmentFromAssumptions() : FunctionPass(ID) {
55  }
56 
57  bool runOnFunction(Function &F) override;
58 
59  void getAnalysisUsage(AnalysisUsage &AU) const override {
63 
64  AU.setPreservesCFG();
70  }
71 
73 };
74 }
75 
77 static const char aip_name[] = "Alignment from assumptions";
78 INITIALIZE_PASS_BEGIN(AlignmentFromAssumptions, AA_NAME,
79  aip_name, false, false)
83 INITIALIZE_PASS_END(AlignmentFromAssumptions, AA_NAME,
85 
87  return new AlignmentFromAssumptions();
88 }
89 
90 // Given an expression for the (constant) alignment, AlignSCEV, and an
91 // expression for the displacement between a pointer and the aligned address,
92 // DiffSCEV, compute the alignment of the displaced pointer if it can be reduced
93 // to a constant. Using SCEV to compute alignment handles the case where
94 // DiffSCEV is a recurrence with constant start such that the aligned offset
95 // is constant. e.g. {16,+,32} % 32 -> 16.
96 static MaybeAlign getNewAlignmentDiff(const SCEV *DiffSCEV,
97  const SCEV *AlignSCEV,
98  ScalarEvolution *SE) {
99  // DiffUnits = Diff % int64_t(Alignment)
100  const SCEV *DiffUnitsSCEV = SE->getURemExpr(DiffSCEV, AlignSCEV);
101 
102  LLVM_DEBUG(dbgs() << "\talignment relative to " << *AlignSCEV << " is "
103  << *DiffUnitsSCEV << " (diff: " << *DiffSCEV << ")\n");
104 
105  if (const SCEVConstant *ConstDUSCEV =
106  dyn_cast<SCEVConstant>(DiffUnitsSCEV)) {
107  int64_t DiffUnits = ConstDUSCEV->getValue()->getSExtValue();
108 
109  // If the displacement is an exact multiple of the alignment, then the
110  // displaced pointer has the same alignment as the aligned pointer, so
111  // return the alignment value.
112  if (!DiffUnits)
113  return cast<SCEVConstant>(AlignSCEV)->getValue()->getAlignValue();
114 
115  // If the displacement is not an exact multiple, but the remainder is a
116  // constant, then return this remainder (but only if it is a power of 2).
117  uint64_t DiffUnitsAbs = std::abs(DiffUnits);
118  if (isPowerOf2_64(DiffUnitsAbs))
119  return Align(DiffUnitsAbs);
120  }
121 
122  return None;
123 }
124 
125 // There is an address given by an offset OffSCEV from AASCEV which has an
126 // alignment AlignSCEV. Use that information, if possible, to compute a new
127 // alignment for Ptr.
128 static Align getNewAlignment(const SCEV *AASCEV, const SCEV *AlignSCEV,
129  const SCEV *OffSCEV, Value *Ptr,
130  ScalarEvolution *SE) {
131  const SCEV *PtrSCEV = SE->getSCEV(Ptr);
132  // On a platform with 32-bit allocas, but 64-bit flat/global pointer sizes
133  // (*cough* AMDGPU), the effective SCEV type of AASCEV and PtrSCEV
134  // may disagree. Trunc/extend so they agree.
135  PtrSCEV = SE->getTruncateOrZeroExtend(
136  PtrSCEV, SE->getEffectiveSCEVType(AASCEV->getType()));
137  const SCEV *DiffSCEV = SE->getMinusSCEV(PtrSCEV, AASCEV);
138  if (isa<SCEVCouldNotCompute>(DiffSCEV))
139  return Align(1);
140 
141  // On 32-bit platforms, DiffSCEV might now have type i32 -- we've always
142  // sign-extended OffSCEV to i64, so make sure they agree again.
143  DiffSCEV = SE->getNoopOrSignExtend(DiffSCEV, OffSCEV->getType());
144 
145  // What we really want to know is the overall offset to the aligned
146  // address. This address is displaced by the provided offset.
147  DiffSCEV = SE->getAddExpr(DiffSCEV, OffSCEV);
148 
149  LLVM_DEBUG(dbgs() << "AFI: alignment of " << *Ptr << " relative to "
150  << *AlignSCEV << " and offset " << *OffSCEV
151  << " using diff " << *DiffSCEV << "\n");
152 
153  if (MaybeAlign NewAlignment = getNewAlignmentDiff(DiffSCEV, AlignSCEV, SE)) {
154  LLVM_DEBUG(dbgs() << "\tnew alignment: " << DebugStr(NewAlignment) << "\n");
155  return *NewAlignment;
156  }
157 
158  if (const SCEVAddRecExpr *DiffARSCEV = dyn_cast<SCEVAddRecExpr>(DiffSCEV)) {
159  // The relative offset to the alignment assumption did not yield a constant,
160  // but we should try harder: if we assume that a is 32-byte aligned, then in
161  // for (i = 0; i < 1024; i += 4) r += a[i]; not all of the loads from a are
162  // 32-byte aligned, but instead alternate between 32 and 16-byte alignment.
163  // As a result, the new alignment will not be a constant, but can still
164  // be improved over the default (of 4) to 16.
165 
166  const SCEV *DiffStartSCEV = DiffARSCEV->getStart();
167  const SCEV *DiffIncSCEV = DiffARSCEV->getStepRecurrence(*SE);
168 
169  LLVM_DEBUG(dbgs() << "\ttrying start/inc alignment using start "
170  << *DiffStartSCEV << " and inc " << *DiffIncSCEV << "\n");
171 
172  // Now compute the new alignment using the displacement to the value in the
173  // first iteration, and also the alignment using the per-iteration delta.
174  // If these are the same, then use that answer. Otherwise, use the smaller
175  // one, but only if it divides the larger one.
176  MaybeAlign NewAlignment = getNewAlignmentDiff(DiffStartSCEV, AlignSCEV, SE);
177  MaybeAlign NewIncAlignment =
178  getNewAlignmentDiff(DiffIncSCEV, AlignSCEV, SE);
179 
180  LLVM_DEBUG(dbgs() << "\tnew start alignment: " << DebugStr(NewAlignment)
181  << "\n");
182  LLVM_DEBUG(dbgs() << "\tnew inc alignment: " << DebugStr(NewIncAlignment)
183  << "\n");
184 
185  if (!NewAlignment || !NewIncAlignment)
186  return Align(1);
187 
188  const Align NewAlign = *NewAlignment;
189  const Align NewIncAlign = *NewIncAlignment;
190  if (NewAlign > NewIncAlign) {
191  LLVM_DEBUG(dbgs() << "\tnew start/inc alignment: "
192  << DebugStr(NewIncAlign) << "\n");
193  return NewIncAlign;
194  }
195  if (NewIncAlign > NewAlign) {
196  LLVM_DEBUG(dbgs() << "\tnew start/inc alignment: " << DebugStr(NewAlign)
197  << "\n");
198  return NewAlign;
199  }
200  assert(NewIncAlign == NewAlign);
201  LLVM_DEBUG(dbgs() << "\tnew start/inc alignment: " << DebugStr(NewAlign)
202  << "\n");
203  return NewAlign;
204  }
205 
206  return Align(1);
207 }
208 
210  unsigned Idx,
211  Value *&AAPtr,
212  const SCEV *&AlignSCEV,
213  const SCEV *&OffSCEV) {
214  Type *Int64Ty = Type::getInt64Ty(I->getContext());
215  OperandBundleUse AlignOB = I->getOperandBundleAt(Idx);
216  if (AlignOB.getTagName() != "align")
217  return false;
218  assert(AlignOB.Inputs.size() >= 2);
219  AAPtr = AlignOB.Inputs[0].get();
220  // TODO: Consider accumulating the offset to the base.
221  AAPtr = AAPtr->stripPointerCastsSameRepresentation();
222  AlignSCEV = SE->getSCEV(AlignOB.Inputs[1].get());
223  AlignSCEV = SE->getTruncateOrZeroExtend(AlignSCEV, Int64Ty);
224  if (!isa<SCEVConstant>(AlignSCEV))
225  // Added to suppress a crash because consumer doesn't expect non-constant
226  // alignments in the assume bundle. TODO: Consider generalizing caller.
227  return false;
228  if (AlignOB.Inputs.size() == 3)
229  OffSCEV = SE->getSCEV(AlignOB.Inputs[2].get());
230  else
231  OffSCEV = SE->getZero(Int64Ty);
232  OffSCEV = SE->getTruncateOrZeroExtend(OffSCEV, Int64Ty);
233  return true;
234 }
235 
237  unsigned Idx) {
238  Value *AAPtr;
239  const SCEV *AlignSCEV, *OffSCEV;
240  if (!extractAlignmentInfo(ACall, Idx, AAPtr, AlignSCEV, OffSCEV))
241  return false;
242 
243  // Skip ConstantPointerNull and UndefValue. Assumptions on these shouldn't
244  // affect other users.
245  if (isa<ConstantData>(AAPtr))
246  return false;
247 
248  const SCEV *AASCEV = SE->getSCEV(AAPtr);
249 
250  // Apply the assumption to all other users of the specified pointer.
253  for (User *J : AAPtr->users()) {
254  if (J == ACall)
255  continue;
256 
257  if (Instruction *K = dyn_cast<Instruction>(J))
258  WorkList.push_back(K);
259  }
260 
261  while (!WorkList.empty()) {
262  Instruction *J = WorkList.pop_back_val();
263  if (LoadInst *LI = dyn_cast<LoadInst>(J)) {
264  if (!isValidAssumeForContext(ACall, J, DT))
265  continue;
266  Align NewAlignment = getNewAlignment(AASCEV, AlignSCEV, OffSCEV,
267  LI->getPointerOperand(), SE);
268  if (NewAlignment > LI->getAlign()) {
269  LI->setAlignment(NewAlignment);
270  ++NumLoadAlignChanged;
271  }
272  } else if (StoreInst *SI = dyn_cast<StoreInst>(J)) {
273  if (!isValidAssumeForContext(ACall, J, DT))
274  continue;
275  Align NewAlignment = getNewAlignment(AASCEV, AlignSCEV, OffSCEV,
276  SI->getPointerOperand(), SE);
277  if (NewAlignment > SI->getAlign()) {
278  SI->setAlignment(NewAlignment);
279  ++NumStoreAlignChanged;
280  }
281  } else if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(J)) {
282  if (!isValidAssumeForContext(ACall, J, DT))
283  continue;
284  Align NewDestAlignment =
285  getNewAlignment(AASCEV, AlignSCEV, OffSCEV, MI->getDest(), SE);
286 
287  LLVM_DEBUG(dbgs() << "\tmem inst: " << DebugStr(NewDestAlignment)
288  << "\n";);
289  if (NewDestAlignment > *MI->getDestAlign()) {
290  MI->setDestAlignment(NewDestAlignment);
291  ++NumMemIntAlignChanged;
292  }
293 
294  // For memory transfers, there is also a source alignment that
295  // can be set.
296  if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) {
297  Align NewSrcAlignment =
298  getNewAlignment(AASCEV, AlignSCEV, OffSCEV, MTI->getSource(), SE);
299 
300  LLVM_DEBUG(dbgs() << "\tmem trans: " << DebugStr(NewSrcAlignment)
301  << "\n";);
302 
303  if (NewSrcAlignment > *MTI->getSourceAlign()) {
304  MTI->setSourceAlignment(NewSrcAlignment);
305  ++NumMemIntAlignChanged;
306  }
307  }
308  }
309 
310  // Now that we've updated that use of the pointer, look for other uses of
311  // the pointer to update.
312  Visited.insert(J);
313  for (User *UJ : J->users()) {
314  Instruction *K = cast<Instruction>(UJ);
315  if (!Visited.count(K))
316  WorkList.push_back(K);
317  }
318  }
319 
320  return true;
321 }
322 
324  if (skipFunction(F))
325  return false;
326 
327  auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
328  ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
329  DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
330 
331  return Impl.runImpl(F, AC, SE, DT);
332 }
333 
335  ScalarEvolution *SE_,
336  DominatorTree *DT_) {
337  SE = SE_;
338  DT = DT_;
339 
340  bool Changed = false;
341  for (auto &AssumeVH : AC.assumptions())
342  if (AssumeVH) {
343  CallInst *Call = cast<CallInst>(AssumeVH);
344  for (unsigned Idx = 0; Idx < Call->getNumOperandBundles(); Idx++)
345  Changed |= processAssumption(Call, Idx);
346  }
347 
348  return Changed;
349 }
350 
353 
357  if (!runImpl(F, AC, &SE, &DT))
358  return PreservedAnalyses::all();
359 
361  PA.preserveSet<CFGAnalyses>();
363  return PA;
364 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
AssumptionCache.h
llvm::ScalarEvolutionAnalysis
Analysis pass that exposes the ScalarEvolution for a function.
Definition: ScalarEvolution.h:2037
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:103
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::initializeAlignmentFromAssumptionsPass
void initializeAlignmentFromAssumptionsPass(PassRegistry &)
getNewAlignmentDiff
static MaybeAlign getNewAlignmentDiff(const SCEV *DiffSCEV, const SCEV *AlignSCEV, ScalarEvolution *SE)
Definition: AlignmentFromAssumptions.cpp:96
llvm::ScalarEvolution::getEffectiveSCEVType
Type * getEffectiveSCEVType(Type *Ty) const
Return a type with the same bitwidth as the given type and which represents how SCEV will treat the g...
Definition: ScalarEvolution.cpp:3949
llvm::AlignmentFromAssumptionsPass::processAssumption
bool processAssumption(CallInst *I, unsigned Idx)
Definition: AlignmentFromAssumptions.cpp:236
llvm::AlignmentFromAssumptionsPass::DT
DominatorTree * DT
Definition: AlignmentFromAssumptions.h:38
llvm::AlignmentFromAssumptionsPass
Definition: AlignmentFromAssumptions.h:29
IntrinsicInst.h
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:779
Scalar.h
llvm::MemTransferInst
This class wraps the llvm.memcpy/memmove intrinsics.
Definition: IntrinsicInst.h:917
llvm::Function
Definition: Function.h:61
llvm::AlignmentFromAssumptionsPass::SE
ScalarEvolution * SE
Definition: AlignmentFromAssumptions.h:37
AlignmentFromAssumptions.h
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::DebugStr
std::string DebugStr(const Align &A)
Definition: Alignment.h:350
Statistic.h
llvm::ScalarEvolution
The main scalar evolution driver.
Definition: ScalarEvolution.h:461
ValueTracking.h
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:151
GlobalsModRef.h
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
Module.h
llvm::LoopInfoWrapperPass
The legacy pass manager's analysis pass to compute loop information.
Definition: LoopInfo.h:1268
llvm::MemIntrinsic
This is the common base class for memset/memcpy/memmove.
Definition: IntrinsicInst.h:874
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::SmallVectorImpl::pop_back_val
LLVM_NODISCARD T pop_back_val()
Definition: SmallVector.h:635
llvm::ScalarEvolution::getTruncateOrZeroExtend
const SCEV * getTruncateOrZeroExtend(const SCEV *V, Type *Ty, unsigned Depth=0)
Return a SCEV corresponding to a conversion of the input value to the specified type.
Definition: ScalarEvolution.cpp:4249
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::ScalarEvolution::getURemExpr
const SCEV * getURemExpr(const SCEV *LHS, const SCEV *RHS)
Represents an unsigned remainder expression based on unsigned division.
Definition: ScalarEvolution.cpp:3251
F
#define F(x, y, z)
Definition: MD5.cpp:56
AliasAnalysis.h
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
Instruction.h
llvm::isValidAssumeForContext
bool isValidAssumeForContext(const Instruction *I, const Instruction *CxtI, const DominatorTree *DT=nullptr)
Return true if it is valid to use the assumptions provided by an assume intrinsic,...
Definition: ValueTracking.cpp:521
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
AA_NAME
#define AA_NAME
Definition: AlignmentFromAssumptions.cpp:39
llvm::User
Definition: User.h:44
Intrinsics.h
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
false
Definition: StackSlotColoring.cpp:142
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:109
llvm::Instruction
Definition: Instruction.h:45
llvm::DominatorTreeWrapperPass
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:287
llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo
bool extractAlignmentInfo(CallInst *I, unsigned Idx, Value *&AAPtr, const SCEV *&AlignSCEV, const SCEV *&OffSCEV)
Definition: AlignmentFromAssumptions.cpp:209
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::ScalarEvolutionWrapperPass
Definition: ScalarEvolution.h:2067
llvm::AlignmentFromAssumptionsPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: AlignmentFromAssumptions.cpp:352
SmallPtrSet.h
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::None
const NoneType None
Definition: None.h:23
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
LoopInfo.h
llvm::ScalarEvolution::getSCEV
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
Definition: ScalarEvolution.cpp:4066
llvm::Value::stripPointerCastsSameRepresentation
const Value * stripPointerCastsSameRepresentation() const
Strip off pointer casts, all-zero GEPs and address space casts but ensures the representation of the ...
Definition: Value.cpp:683
llvm::SCEV
This class represents an analyzed expression in the program.
Definition: ScalarEvolution.h:78
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:304
uint64_t
llvm::AssumptionAnalysis
A function analysis which provides an AssumptionCache.
Definition: AssumptionCache.h:169
llvm::PreservedAnalyses::preserve
void preserve()
Mark an analysis as preserved.
Definition: PassManager.h:176
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::SCEVConstant
This class represents a constant integer value.
Definition: ScalarEvolutionExpressions.h:47
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::ScalarEvolution::getNoopOrSignExtend
const SCEV * getNoopOrSignExtend(const SCEV *V, Type *Ty)
Return a SCEV corresponding to a conversion of the input value to the specified type.
Definition: ScalarEvolution.cpp:4286
llvm::SmallPtrSetImpl::count
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:382
llvm::AssumptionCacheTracker
An immutable pass that tracks lazily created AssumptionCache objects.
Definition: AssumptionCache.h:200
llvm::AnalysisUsage::setPreservesCFG
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:253
llvm::AssumptionCache
A cache of @llvm.assume calls within a function.
Definition: AssumptionCache.h:41
llvm::CFGAnalyses
Represents analyses that only rely on functions' control flow.
Definition: PassManager.h:116
llvm::AnalysisUsage::addPreserved
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Definition: PassAnalysisSupport.h:98
llvm::OperandBundleUse
A lightweight accessor for an operand bundle meant to be passed around by value.
Definition: InstrTypes.h:1056
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:175
llvm::OperandBundleUse::Inputs
ArrayRef< Use > Inputs
Definition: InstrTypes.h:1057
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition: EntryExitInstrumenter.cpp:69
Constant.h
aip_name
static const char aip_name[]
Definition: AlignmentFromAssumptions.cpp:77
llvm::Type::getInt64Ty
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:204
llvm::ScalarEvolution::getMinusSCEV
const SCEV * getMinusSCEV(const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Return LHS-RHS.
Definition: ScalarEvolution.cpp:4199
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:161
llvm::createAlignmentFromAssumptionsPass
FunctionPass * createAlignmentFromAssumptionsPass()
Definition: AlignmentFromAssumptions.cpp:86
llvm::SCEVAddRecExpr
This node represents a polynomial recurrence on the trip count of the specified loop.
Definition: ScalarEvolutionExpressions.h:352
getNewAlignment
static Align getNewAlignment(const SCEV *AASCEV, const SCEV *AlignSCEV, const SCEV *OffSCEV, Value *Ptr, ScalarEvolution *SE)
Definition: AlignmentFromAssumptions.cpp:128
ScalarEvolutionExpressions.h
llvm::DominatorTreeAnalysis
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:252
Instructions.h
llvm::PreservedAnalyses::preserveSet
void preserveSet()
Mark an analysis set as preserved.
Definition: PassManager.h:191
llvm::OperandBundleUse::getTagName
StringRef getTagName() const
Return the tag of this operand bundle as a string.
Definition: InstrTypes.h:1075
llvm::AssumptionCache::assumptions
MutableArrayRef< ResultElem > assumptions()
Access the list of assumption handles currently tracked for this function.
Definition: AssumptionCache.h:146
Dominators.h
llvm::AAResultsWrapperPass
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
Definition: AliasAnalysis.h:1281
llvm::GlobalsAAWrapperPass
Legacy wrapper pass to provide the GlobalsAAResult object.
Definition: GlobalsModRef.h:143
llvm::ScalarEvolution::getZero
const SCEV * getZero(Type *Ty)
Return a SCEV for the constant 0 of a specific type.
Definition: ScalarEvolution.h:626
llvm::AlignmentFromAssumptionsPass::runImpl
bool runImpl(Function &F, AssumptionCache &AC, ScalarEvolution *SE_, DominatorTree *DT_)
Definition: AlignmentFromAssumptions.cpp:334
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(AlignmentFromAssumptions, AA_NAME, aip_name, false, false) INITIALIZE_PASS_END(AlignmentFromAssumptions
llvm::SCEV::getType
Type * getType() const
Return the LLVM type of this SCEV expression.
Definition: ScalarEvolution.cpp:379
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::ScalarEvolution::getAddExpr
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
Definition: ScalarEvolution.cpp:2419
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1475
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
raw_ostream.h
llvm::isPowerOf2_64
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Definition: MathExtras.h:496
llvm::abs
APFloat abs(APFloat X)
Returns the absolute value of the argument.
Definition: APFloat.h:1284
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
Debug.h
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:422
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:364
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37