[PATCH] InstCombine: simplify signed range checks

Erik Eckstein eeckstein at apple.com
Wed Dec 3 02:41:22 PST 2014


commited in r223224

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:792
@@ +791,3 @@
+/// (icmp slt x, 0) | (icmp sgt x, n) --> icmp ugt x, n
+Value *InstCombiner::simplifyRangeCheck(ICmpInst *Cmp0, ICmpInst *Cmp1,
+                                        bool Inverted) {
----------------
reames wrote:
> Minor style: I might hide the boolean parameter behind a helper function.  It would help readability at the call site.
> 
> simplifyRangeCheck(A,B) { return simplifyRangeCheckImpl(A,B,false); }
> simplifyInvertedRangeCheck(A,B) { return simplifyRangeCheckImpl(A,B, true); }
I added a /*Inverted=*/ comment at the call sites. This should improve readability as well.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:806
@@ +805,3 @@
+      !(Pred0 == ICmpInst::ICMP_SGE && RangeStart->isZero()))
+    return nullptr;
+
----------------
reames wrote:
> This would be clearer as:
> if (!(a || b))
> 
> Minor, feel free to ignore if you disagree.
done

http://reviews.llvm.org/D6422






More information about the llvm-commits mailing list