[PATCH] D85865: [ConstProp] Handle insertelement constants
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 14:45:52 PDT 2020
aeubanks added inline comments.
================
Comment at: llvm/lib/IR/ConstantFold.cpp:858
+ if (const auto *IEIdx = dyn_cast<ConstantInt>(CE->getOperand(2))) {
+ if (IEIdx->equalsInt(CIdx->getZExtValue())) {
+ if (auto *IEValue = dyn_cast<Constant>(CE->getOperand(1)))
----------------
efriedma wrote:
> aeubanks wrote:
> > efriedma wrote:
> > > Oh, also, please avoid using getZExtValue() on constants that don't have a known width; it asserts the number is less than 2^64. Unfortunately, there isn't any convenient way to do this comparison at the moment; I guess you could use APSInt::isSameValue.
> > Is APInt::eq() good?
> IDIdx and CIdx might not have the same bitwidth, I think; the index of an insertelement/extractelement can have any type. APInt::eq asserts if the widths aren't equal.
Ah yes, I changed one of the types in the new test and repro'd. Now using APSInt::isSameValue().
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