[PATCH] D142345: [X86] Transform `(icmp eq/ne Abs(A), Pow2)` -> `(and/or (icmp eq/ne A,Pow2), (icmp eq/ne A,-Pow2))`

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 10:29:24 PST 2023


RKSimon added a comment.

Please can you add alive links?



================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:53410
+
+      if (LHS.getOpcode() == ISD::ABS && LHS.hasOneUse()) {
+        if (auto *C = dyn_cast<ConstantSDNode>(RHS)) {
----------------
Add comment explaining the fold:
```
// Fold (icmp eq/ne Abs(A), Pow2)
//  --> (or/and (icmp eq/ne A,Pow2), (icmp eq/ne A,-Pow2))
```


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:53414
+          // We can better optimize this case in DAGCombiner::foldAndOrOfSETCC.
+          if (CInt.isPowerOf2() && !CInt.isZero() && !CInt.isMinSignedValue()) {
+            SDValue BaseOp = LHS.getOperand(0);
----------------
APInt::isPowerOf2() shouldn't require a isZero check?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142345



More information about the llvm-commits mailing list