[PATCH] D47980: [InstCombine] Fold (x << y) >> y -> x & (-1 >> y)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 17 11:07:36 PDT 2018
lebedev.ri added inline comments.
================
Comment at: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp:741-744
// (X << C1) >>u C2 --> (X >>u (C2 - C1)) & (-1 >> C2)
Value *NewLShr = Builder.CreateLShr(X, ShiftDiff, "", I.isExact());
APInt Mask(APInt::getLowBitsSet(BitWidth, BitWidth - ShAmt));
return BinaryOperator::CreateAnd(NewLShr, ConstantInt::get(Ty, Mask));
----------------
BTW it's interesting to note that all these masks are not fine-grained, isn't it?
Alive says https://rise4fun.com/Alive/Yes (lol)
Though in practice, from what i have seen from the tests, somehow the mask seems to be adjusted later.
Repository:
rL LLVM
https://reviews.llvm.org/D47980
More information about the llvm-commits
mailing list