[PATCH] D127122: [InstCombine] reduce right-shift-of-left-shifted constant via demanded bits
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 6 12:41:59 PDT 2022
spatel marked an inline comment as done.
spatel added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:640
+ const APInt *C;
+ if (match(I->getOperand(0), m_Shl(m_APInt(C), m_Value(X))) &&
+ C->countTrailingZeros() >= ShiftAmt) {
----------------
RKSimon wrote:
> Why limit this to (scalar) constants instead of using KnownBits::countMinTrailingZeros?
Mainly because that was always part of the motivating examples. :)
If we use known bits here, then the new lshr is potentially not constant-folded away. We could do that, but then we would need to limit the match with one-use.
I don't have a strong preference. We could make it another small follow-on if that seems like a better transform.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127122/new/
https://reviews.llvm.org/D127122
More information about the llvm-commits
mailing list