[PATCH] D145846: [InstCombine] enhance icmp with sub folds
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 21 07:55:51 PDT 2023
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4096
+ if (match(&I, m_c_ICmp(Pred, m_OneUse(m_Neg(m_Value(X))), m_Deferred(X))) &&
+ (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_EQ)) {
+ Type *Ty = X->getType();
----------------
nikic wrote:
> Use `ICmpInst::isEquality()`.
isEquality() means "EQ" or "NE". You don't need to check for ICMP_NE separately.
================
Comment at: llvm/test/Transforms/InstCombine/icmp-sub.ll:596
-; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SUB]], [[A]]
; CHECK-NEXT: ret i1 [[CMP]]
----------------
These end up not actually commuted due to complexity-based canonicalization. Grep for `thwart complexity-based canonicalization` for how to avoid it.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145846/new/
https://reviews.llvm.org/D145846
More information about the llvm-commits
mailing list