[PATCH] InstCombine: simplify signed range checks

Philip Reames listmail at philipreames.com
Tue Dec 2 17:54:36 PST 2014


LGTM.

================
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) {
----------------
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); }

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

Minor, feel free to ignore if you disagree.

http://reviews.llvm.org/D6422






More information about the llvm-commits mailing list