[PATCH] D85865: [ConstProp] Handle insertelement constants

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 12:04:18 PDT 2020


efriedma added inline comments.


================
Comment at: llvm/lib/IR/ConstantFold.cpp:859
+        if (IEIdx->equalsInt(CIdx->getZExtValue())) {
+          if (auto *IEValue = dyn_cast<Constant>(CE->getOperand(1)))
+            return IEValue;
----------------
`CE->getOperand(1)` should return a Constant*; you don't need to dyn_cast<> it.


================
Comment at: llvm/lib/IR/Constants.cpp:421
+        if (auto *IEValue = dyn_cast<Constant>(IE->getOperand(1)))
+          return IEValue;
+      }
----------------
aeubanks wrote:
> efriedma wrote:
> > Can we also fold in the case where the indexes are known not-equal?
> Do you mean recursively search the vector operand?
Sort of.  I was thinking of something like `return ConstantExpr::getExtractElement(IE->getOperand(0), CIdx);`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85865/new/

https://reviews.llvm.org/D85865



More information about the llvm-commits mailing list