[llvm] dc63d61 - [ConstantFold] Push extractelement into getelementptr's operands
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 03:34:51 PDT 2019
Author: Jay Foad
Date: 2019-10-29T10:31:52Z
New Revision: dc63d6175aa5692db1670dc9ee7a1f304e752d87
URL: https://github.com/llvm/llvm-project/commit/dc63d6175aa5692db1670dc9ee7a1f304e752d87
DIFF: https://github.com/llvm/llvm-project/commit/dc63d6175aa5692db1670dc9ee7a1f304e752d87.diff
LOG: [ConstantFold] Push extractelement into getelementptr's operands
This fixes a minor oversight mentioned in the review of D69379:
we should push extractelement into the operands of getelementptr
regardless of whether that enables further folding.
Added:
Modified:
llvm/lib/IR/ConstantFold.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 84b117de21e6..a6cd83310088 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -808,7 +808,7 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val,
for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i) {
Constant *Op = CE->getOperand(i);
if (Op->getType()->isVectorTy()) {
- Constant *ScalarOp = ConstantFoldExtractElementInstruction(Op, Idx);
+ Constant *ScalarOp = ConstantExpr::getExtractElement(Op, Idx);
if (!ScalarOp)
return nullptr;
Ops.push_back(ScalarOp);
More information about the llvm-commits
mailing list