[PATCH] D141188: [MergeICmps] Adapt to non-eq comparisons

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 03:57:42 PST 2023


courbet added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/MergeICmps.cpp:352
+    const auto *const ConstBase = cast<ConstantInt>(Baseline);
+    ExpectedPredicate =
+        ConstBase->isOne() ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ;
----------------
Let's `assert` that `ConstBase` is an `i1` here, because `isOne()` would be incorrect otherwise.


================
Comment at: llvm/lib/Transforms/Scalar/MergeICmps.cpp:674
         Builder, DL, &TLI);
-    IsEqual = Builder.CreateICmpEQ(
-        MemCmpCall, ConstantInt::get(Builder.getIntNTy(IntBits), 0));
+    IsEqual = Builder.CreateICmp(
+        Predicate, MemCmpCall, ConstantInt::get(Builder.getIntNTy(IntBits), 0));
----------------
nit: this is no longer `IsEqual`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141188/new/

https://reviews.llvm.org/D141188



More information about the llvm-commits mailing list