diff options
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index f5da963..01092b4 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1098,6 +1098,12 @@ Constant *ConstantFoldInstOperandsImpl(const Value *InstOrCE, unsigned Opcode, case Instruction::ShuffleVector: return ConstantExpr::getShuffleVector( Ops[0], Ops[1], cast<ShuffleVectorInst>(InstOrCE)->getShuffleMask()); + case Instruction::Load: { + const auto *LI = dyn_cast<LoadInst>(InstOrCE); + if (LI->isVolatile()) + return nullptr; + return ConstantFoldLoadFromConstPtr(Ops[0], LI->getType(), DL); + } } } @@ -1188,12 +1194,6 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const DataLayout &DL, Ops.push_back(Op); } - if (const auto *LI = dyn_cast<LoadInst>(I)) { - if (LI->isVolatile()) - return nullptr; - return ConstantFoldLoadFromConstPtr(Ops[0], LI->getType(), DL); - } - return ConstantFoldInstOperands(I, Ops, DL, TLI); } |