[PATCH] D83127: [InstCombine] canEvaluateTruncated - use KnownBits to check for inrange shift amounts
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 06:26:08 PDT 2020
lebedev.ri added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:398
+ llvm::computeKnownBits(I->getOperand(1), IC.getDataLayout());
+ APInt ShiftedBits = APInt::getBitsSetFrom(OrigBitWidth, BitWidth);
+ if (AmtKnownBits.getMaxValue().ult(BitWidth) &&
----------------
Shouldn't this take `AmtKnownBits.getMaxValue()` into account?
I.e. if we are truncating `i32 -> i16`, but are shifting by at most `1`,
we don't need for all bits under mask `0xFFFF0000` to be zeros,
we only need that for the bits we'd potentially shift-in,
i.e. only `0x10000`. Or am i missing something?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83127/new/
https://reviews.llvm.org/D83127
More information about the llvm-commits
mailing list