[PATCH] D154791: [InstCombine] Transform bitwise (A >> C - 1, zext(icmp)) -> zext (bitwise(A < 0, icmp)) fold.

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 09:47:34 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1716
 
-  // ( A << (X - 1) ) | ((A > 0) zext to iX)
-  // <=> A < 0 | A > 0
-  // <=> (A != 0) zext to iX
-  Value *A;
-  ICmpInst::Predicate Pred;
+  // fold and/or(A << BW - 1, zext(icmp))     (BW is the scalar bits of the type of A)
+  //   -> and/or(zext(A < 0), zext(icmp))
----------------
comment incorrect shift.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1726
+                          m_SpecificInt(Op0->getType()->getScalarSizeInBits() - 1))) &&
+        match(Op1, m_ZExt(m_ICmp(Pred, m_Value(), m_Value()))) &&
+        LogicOpc != Instruction::Xor;
----------------
Does `Op1` need to be an `icmp`, or can it just be any `i1`?


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1727
+        match(Op1, m_ZExt(m_ICmp(Pred, m_Value(), m_Value()))) &&
+        LogicOpc != Instruction::Xor;
+
----------------
nit:: LogicOp != Instruction::Xor should go before the `match(...)` imo.


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

https://reviews.llvm.org/D154791



More information about the llvm-commits mailing list