[ConstantFold] Push extractelement into getelementptr's operands
authorJay Foad <jay.foad@amd.com>
Tue, 29 Oct 2019 10:31:52 +0000 (10:31 +0000)
committerJay Foad <jay.foad@amd.com>
Tue, 29 Oct 2019 10:31:52 +0000 (10:31 +0000)
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.

llvm/lib/IR/ConstantFold.cpp

index 84b117d..a6cd833 100644 (file)
@@ -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);