[PATCH] D36498: [InstCombine] Teach foldSelectICmpAnd to recognize a (icmp slt trunc X, 0) and (icmp sgt trunc X, -1) as equivalent to an and with the sign bit of the truncated type

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 14:22:19 PDT 2017


spatel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:631
+    AndMask = *AndRHS;
+    IsEqualZero = IC->getPredicate() == ICmpInst::ICMP_EQ;
+  } else if (decomposeBitTestICmp(IC->getOperand(0), IC->getOperand(1),
----------------
'IC->getPredicate()' can be shortened to 'Pred'?


================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:634
+                                  Pred, V, AndMask)) {
+    assert(ICmpInst::isEquality(Pred) && "Not equality test?");
+
----------------
IsEqualZero is not initialized on this path.


================
Comment at: test/Transforms/InstCombine/select-with-bitwise-ops.ll:496-498
+; CHECK-NEXT:    [[TMP1:%.*]] = lshr <2 x i32> [[X:%.*]], <i32 30, i32 30>
+; CHECK-NEXT:    [[TMP2:%.*]] = and <2 x i32> [[TMP1]], <i32 2, i32 2>
+; CHECK-NEXT:    [[TMP3:%.*]] = xor <2 x i32> [[TMP2]], <i32 42, i32 42>
----------------
This is miscompiling:
http://rise4fun.com/Alive/ACO

Should be the same ops as the scalar test?


https://reviews.llvm.org/D36498





More information about the llvm-commits mailing list