[PATCH] D105764: [InstCombine] Fold lshr/ashr(or(neg(x), x), bw-1) --> zext/sext(icmp_ne(x,0)) (PR50816)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 13 06:10:02 PDT 2021
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
LG
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:1144-1145
+ if (match(Op0, m_OneUse(m_c_Or(m_Neg(m_Value(X)), m_Deferred(X))))) {
+ Constant *Zero = ConstantInt::get(Ty, 0);
+ return new ZExtInst(Builder.CreateICmpNE(X, Zero), Ty);
+ }
----------------
Could use `Builder.CreateIsNotNull()`
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:1335-1336
+ if (match(Op0, m_OneUse(m_c_Or(m_Neg(m_Value(X)), m_Deferred(X))))) {
+ Constant *Zero = ConstantInt::get(Ty, 0);
+ return new SExtInst(Builder.CreateICmpNE(X, Zero), Ty);
+ }
----------------
Same
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105764/new/
https://reviews.llvm.org/D105764
More information about the llvm-commits
mailing list