[PATCH] D49229: [InstCombine] Fold redundant masking operations of shifted value
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 24 05:07:21 PDT 2018
lebedev.ri added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2031
+ // 2nd: Find out which AND is which
+ BinaryOperator *And = cast<BinaryOperator>(A), *Shift, *ShtAnd;
+ if (And->getOperand(0) != X) {
----------------
This is super subtle, defining more variables after the first one which is being initialized,
================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2042-2046
+ OtherMask = AndC->shl(ShftAmt->getZExtValue());
+ else if (Instruction::LShr == Opcode)
+ OtherMask = AndC->lshr(ShftAmt->getZExtValue());
+ else
+ OtherMask = AndC->ashr(ShftAmt->getZExtValue());
----------------
lebedev.ri wrote:
> This will miscompile with types larger than i64.
> Please add tests.
Hmm, no, actually. disregard that.
If the shift is too large, then that old shift would have been folded to `undef` already.
https://reviews.llvm.org/D49229
More information about the llvm-commits
mailing list