[PATCH] D20289: [InstCombine] check vector elements before trying to transform LE/GE vector icmp (PR27756)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 14:29:13 PDT 2016


spatel added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3138-3140
@@ +3137,5 @@
+
+  // Check if all elements of the constant can be safely incremented/decremented
+  // without overflowing/underflowing.
+  auto allElementsValid = [](Constant *VecConst, bool IsLT, bool IsSigned) {
+    unsigned NumElts = VecConst->getType()->getVectorNumElements();
----------------
chandlerc wrote:
> Instead of the bool flags here, I would pass in the predicate value and handle that internally.
> 
> With that, I tihnk you can completely eliminate the switch in the calling code as the only other difference is 1 vs. -1.
We still have to choose 1 of the 4 predicate values, but I'll take the anti-switch bait. :)
Lets try for max density via ?: and see if that reads better.


http://reviews.llvm.org/D20289





More information about the llvm-commits mailing list