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

Shivam Gupta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 30 21:14:04 PDT 2023


xgupta marked an inline comment as done.
xgupta added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2952
+  // (icmp eq A, -1) & (icmp eq B, -1) --> (icmp eq (A&B), -1)
+  // TODO: Remove this when foldLogOpOfMaskedICmps can handle undefs.
+  if (!IsLogical && PredL == (IsAnd ? ICmpInst::ICMP_EQ : ICmpInst::ICMP_NE) &&
----------------
goldstein.w.n wrote:
> Is there why this patch adds this new functionality and doesn't juist update `foldLogOpOfMaskedICmps` to handle undefs? Is it alot of work?
I have not thought about that, I will try to explore that. 
I wrote this as similar to a few line above for  (icmp eq A, 0) & (icmp eq B, 0) --> (icmp eq (A|B), 0)"


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2958
+    return Builder.CreateICmp(PredL, NewAnd,
+                              ConstantInt::get(LHS0->getType(), -1));
+  }
----------------
goldstein.w.n wrote:
> `ConstantInt::get(LHS0->getType(), -1)` -> `Constant::getAllOnesValue(LHS0->getType())`
Thanks, updated.


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