32bool UnrolledInstAnalyzer::simplifyInstWithSCEV(
Instruction *
I) {
33 if (!SE.isSCEVable(
I->getType()))
36 const SCEV *S = SE.getSCEV(
I);
38 SimplifiedValues[
I] = SC->getValue();
44 if (!IterationNumber->isZero() && SE.isLoopInvariant(S, L))
48 if (!AR || AR->getLoop() != L)
51 const SCEV *ValueAtIteration = AR->evaluateAtIteration(IterationNumber, SE);
54 SimplifiedValues[
I] = SC->getValue();
62 std::optional<APInt>
Offset =
63 SE.computeConstantDifference(ValueAtIteration, Base);
67 Address.Base = Base->getValue();
81 if (
Value *SimpleLHS = SimplifiedValues.lookup(
LHS))
84 if (
Value *SimpleRHS = SimplifiedValues.lookup(
RHS))
87 Value *SimpleV =
nullptr;
88 const DataLayout &
DL =
I.getDataLayout();
96 SimplifiedValues[&
I] = SimpleV;
103bool UnrolledInstAnalyzer::visitLoad(
LoadInst &
I) {
104 Value *AddrOp =
I.getPointerOperand();
106 auto AddressIt = SimplifiedAddresses.find(AddrOp);
107 if (AddressIt == SimplifiedAddresses.end())
113 if (!GV || !GV->hasDefinitiveInitializer() || !GV->isConstant())
118 AddressIt->second.Offset,
I.getDataLayout());
122 SimplifiedValues[&
I] = Res;
127bool UnrolledInstAnalyzer::visitCastInst(
CastInst &
I) {
129 if (
Value *Simplified = SimplifiedValues.lookup(
Op))
136 const DataLayout &
DL =
I.getDataLayout();
138 SimplifiedValues[&
I] =
V;
147bool UnrolledInstAnalyzer::visitCmpInst(
CmpInst &
I) {
152 if (
Value *SimpleLHS = SimplifiedValues.lookup(
LHS))
155 if (
Value *SimpleRHS = SimplifiedValues.lookup(
RHS))
159 auto SimplifiedLHS = SimplifiedAddresses.find(
LHS);
160 if (SimplifiedLHS != SimplifiedAddresses.end()) {
161 auto SimplifiedRHS = SimplifiedAddresses.find(
RHS);
162 if (SimplifiedRHS != SimplifiedAddresses.end()) {
163 SimplifiedAddress &LHSAddr = SimplifiedLHS->second;
164 SimplifiedAddress &RHSAddr = SimplifiedRHS->second;
165 if (LHSAddr.Base == RHSAddr.Base) {
180 const DataLayout &
DL =
I.getDataLayout();
182 SimplifiedValues[&
I] =
V;
189bool UnrolledInstAnalyzer::visitPHINode(
PHINode &PN) {
199bool UnrolledInstAnalyzer::visitInstruction(
Instruction &
I) {
200 return simplifyInstWithSCEV(&
I);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This is the base class for all instructions that perform data casts.
static LLVM_ABI bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
This class is the base class for the comparison instructions.
static LLVM_ABI ConstantInt * getBool(LLVMContext &Context, bool V)
static LLVM_ABI bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
bool visitCmpInst(CmpInst &I)
bool visitPHINode(PHINode &I)
bool visitBinaryOperator(BinaryOperator &I)
bool visitCastInst(CastInst &I)
An instruction for reading from memory.
const ParentTy * getParent() const
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Value * simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, const SimplifyQuery &Q)
Given operands for a CastInst, fold the result or return null.
LLVM_ABI Constant * ConstantFoldLoadFromConst(Constant *C, Type *Ty, const APInt &Offset, const DataLayout &DL)
Extract value of C at the given Offset reinterpreted as Ty.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI Value * simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a BinaryOperator, fold the result or return null.
DWARFExpression::Operation Op
LLVM_ABI Value * simplifyCmpInst(CmpPredicate Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a CmpInst, fold the result or return null.