[PATCH] D17873: [InstCombine] (icmp sgt smin(PosA, B) 0) -> (icmp sgt B 0)

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 4 13:33:51 PST 2016


sanjoy requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3181
@@ +3180,3 @@
+        if (SPR.Flavor == SPF_SMIN) {
+          if (isKnownNonNegative(A, DL) && isKnownNonZero(A, DL))
+            return new ICmpInst(I.getPredicate(), B, CI);
----------------
This is more work for you, but I think the right thing to do here is introduce an `isKnownPositive` helper in ValueTracking.h -- doing two recursive walks on the same expression seems wasteful.

I'd say lets start with a simple `isKnownPositive` implementation (maybe one that just looks at `!range` metadata and `computeKnownBits`), which we can evolve in the future.



http://reviews.llvm.org/D17873





More information about the llvm-commits mailing list