[PATCH] D148744: [InstCombine] Refactor foldSelectICmpAndOr to use `decomposeBitTestICmp` instead of bespoke logic

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 07:21:25 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:692
+    APInt C1;
+    if (!decomposeBitTestICmp(CmpLHS, CmpRHS, Pred, Unused, C1) ||
+        !C1.isPowerOf2())
----------------
Probably better to pass CmpLHS instead of Unused? They'll always be the same without LookThruTrunc, but that seems more robust.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:697
+    C1Log = C1.logBase2();
+    NeedAnd = !match(CmpRHS, m_SpecificInt(C1));
   }
----------------
I don't really get why this isn't `NeedAnd = true` any more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148744



More information about the llvm-commits mailing list