[PATCH] D154126: [InstCombine] Transform (A > 0) | (A < 0) -> zext (A != 0) fold

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 30 08:44:15 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1724
+  auto MatchOrZextIcmp = [&](Value *Op0, Value *Op1) -> bool {
+    return match(Op0, m_LShr(m_Value(A), m_Constant(B))) &&
+           match(Op1, m_ZExt(m_ICmp(Pred, m_Specific(A), m_Zero())));
----------------
Since you only use the constant as a splat just match `B` as an `m_APInt(B)`. And make `B` a `const APInt *`.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1737
+
+    if (Pred == ICmpInst::ICMP_SGT && MatchBAndX) {
+      Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_NE, A,
----------------
The `Pred == ICmpInst::ICMP_SGT` should probably be at the top when you check that logicop is `Or`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154126



More information about the llvm-commits mailing list