[PATCH] D12210: [InstCombine] Transform A & (L - 1) u< L --> L != 0

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 13:42:37 PDT 2015


majnemer added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3495-3498
@@ +3494,6 @@
+    if (BO0) {
+      // Transform  A & (L - 1) `ult` L --> L != 0
+      Value *L;
+      auto LSubOne = m_CombineOr(m_Sub(m_Value(L), m_SpecificInt(1)),
+                                 m_Add(m_Value(L), m_AllOnes()));
+      auto BitwiseAnd =
----------------
Isn't `X - 1` always canonicalized to `X + -1` ?  Your transform is permitted to assume canonicalization occurred earlier.

================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3504
@@ +3503,3 @@
+          I.getPredicate() == ICmpInst::ICMP_ULT) {
+        auto *Zero = ConstantInt::getSigned(BO0->getType(), 0);
+        return new ICmpInst(ICmpInst::ICMP_NE, L, Zero);
----------------
Might be more concise as `auto *Zero = Constant::getNullValue(BO0->getType());`


http://reviews.llvm.org/D12210





More information about the llvm-commits mailing list