[PATCH] D111410: [InstCombine] generalize fold for mask-with-signbit-splat
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 8 07:50:27 PDT 2021
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
Hm, looks fine to me.
I guess there's also the 'commutative' variant: https://alive2.llvm.org/ce/z/t8iHTy
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2067
- // and(ashr(subNSW(Y, X), ScalarSizeInBits(Y)-1), X) --> X s> Y ? X : 0.
- if (match(&I, m_c_And(m_OneUse(m_AShr(
- m_NSWSub(m_Value(Y), m_Value(X)),
- m_SpecificInt(Ty->getScalarSizeInBits() - 1))),
- m_Deferred(X)))) {
- Value *NewICmpInst = Builder.CreateICmpSGT(X, Y);
- return SelectInst::Create(NewICmpInst, X, ConstantInt::getNullValue(Ty));
+ // (iN X s>> (N-1)) & Y --> (X < 0) ? Y : 0
+ unsigned FullShift = Ty->getScalarSizeInBits() - 1;
----------------
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111410/new/
https://reviews.llvm.org/D111410
More information about the llvm-commits
mailing list