[PATCH] D40012: [InstSimplify] More fcmp cases when comparing against negative constants.

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 08:27:21 PST 2017


spatel added a comment.

The tests should go under tests/Transforms/InstSimplify since this is handled outside of InstCombine.
I went ahead and added variants of the original tests plus a couple of extras with r319041. The extra tests show at least one possible extension to handle other fcmp predicates. A more general extension might involve a range test rather than using CannotBeOrderedLessThanZero()?



================
Comment at: lib/Analysis/InstructionSimplify.cpp:3331-3332
     }
-    if (CFP->getValueAPF().isZero()) {
+    if (CFP->getValueAPF().isZero() ||
+        (CFP->getValueAPF().isNegative() && !CFP->getValueAPF().isNaN())) {
       switch (Pred) {
----------------
We've already handled isNaN above here? Could assert instead of re-checking that condition or just remove it.


================
Comment at: lib/Analysis/InstructionSimplify.cpp:3336
         if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
           return getTrue(RetTy);
         break;
----------------
Should add a comment for symmetry:
X > 0 or X > -C


https://reviews.llvm.org/D40012





More information about the llvm-commits mailing list