28 if (
auto *LI = dyn_cast<LoadInst>(
I)) {
29 Value *PtrOp = LI->getPointerOperand();
30 Align OldAlign = LI->getAlign();
31 Align NewAlign = Fn(PtrOp, OldAlign,
DL.getPrefTypeAlign(LI->getType()));
32 if (NewAlign > OldAlign) {
33 LI->setAlignment(NewAlign);
36 }
else if (
auto *SI = dyn_cast<StoreInst>(
I)) {
37 Value *PtrOp = SI->getPointerOperand();
38 Value *ValOp = SI->getValueOperand();
39 Align OldAlign = SI->getAlign();
40 Align NewAlign = Fn(PtrOp, OldAlign,
DL.getPrefTypeAlign(ValOp->
getType()));
41 if (NewAlign > OldAlign) {
42 SI->setAlignment(NewAlign);
60 if (PrefAlign > OldAlign)
61 return std::max(OldAlign,
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool tryToImproveAlign(const DataLayout &DL, Instruction *I, function_ref< Align(Value *PtrOp, Align OldAlign, Align PrefAlign)> Fn)
bool inferAlignment(Function &F, AssumptionCache &AC, DominatorTree &DT)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
A function analysis which provides an AssumptionCache.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
A parsed version of the target data layout string in and methods for querying it.
Analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
Align tryEnforceAlignment(Value *V, Align PrefAlign, const DataLayout &DL)
If the specified pointer points to an object that we control, try to modify the object's alignment to...
This struct is a compact representation of a valid (non-zero power of two) alignment.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
unsigned getBitWidth() const
Get the bit width of this value.