[PATCH] D151660: [InstCombine] (icmp eq A, -1) & (icmp eq B, -1) --> (icmp eq (A&B), -1)

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 13:59:37 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2955
+      PredL == PredR && match(LHS1, m_ConstantInt<-1>()) &&
+      match(RHS1, m_ConstantInt<-1>()) && LHS0->getType() == RHS0->getType()) {
+    Value *NewAnd = Builder.CreateAnd(LHS0, RHS0);
----------------
`m_ConstantInt<-1>()` -> `m_AllOnes()`


================
Comment at: llvm/test/Transforms/InstCombine/pr62311.ll:75
+  ret i1 %0
+}
----------------
This single test isn't really sufficient.

Can you add a few more simple tests covering the following cases:

1) (x == -1 && y == -1)
2) (x != -1) || (y != -1)
3) (x == -1) || (y == -1) -- failure case
4) (x == -1) && (y != -1) -- failure case

maybe a few more failure cases using other constants / mismatched constants.
Something in the style of `icmp-add.ll` should be fine.
 
Can you also split the patch with the tests so we can more easily see the diff generated by this patch.

I.e

Patch1: Test Cases
Patch2: Implementation

Then match patch2 the parent of patch1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151660



More information about the llvm-commits mailing list