[llvm] 0ee2245 - ValueTracking: Restore ordered negative handling for frem

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 06:38:45 PDT 2023


Author: Matt Arsenault
Date: 2023-05-16T14:38:39+01:00
New Revision: 0ee2245ab2232e454151e5c9d1637cde4686ee9c

URL: https://github.com/llvm/llvm-project/commit/0ee2245ab2232e454151e5c9d1637cde4686ee9c
DIFF: https://github.com/llvm/llvm-project/commit/0ee2245ab2232e454151e5c9d1637cde4686ee9c.diff

LOG: ValueTracking: Restore ordered negative handling for frem

In D148674, the negative condition was weakened to only
checking isKnownNever(fcNegative), instead of cannotBeOrderedLessThanZero().

This avoids a regression when CannotBeOrderedLessThanZero is
replaced with computeKnownFPClass.

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp
    llvm/test/Transforms/Attributor/nofpclass-frem.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 5947a68746c0..28b4fc454c14 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -5179,6 +5179,12 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
       }
 
       // The sign for frem is the same as the first operand.
+      if (KnownLHS.cannotBeOrderedLessThanZero())
+        Known.knownNot(KnownFPClass::OrderedLessThanZeroMask);
+      if (KnownLHS.cannotBeOrderedGreaterThanZero())
+        Known.knownNot(KnownFPClass::OrderedGreaterThanZeroMask);
+
+      // See if we can be more aggressive about the sign of 0.
       if (KnownLHS.isKnownNever(fcNegative))
         Known.knownNot(fcNegative);
       if (KnownLHS.isKnownNever(fcPositive))

diff  --git a/llvm/test/Transforms/Attributor/nofpclass-frem.ll b/llvm/test/Transforms/Attributor/nofpclass-frem.ll
index 930b1a77da57..77b697e4dca5 100644
--- a/llvm/test/Transforms/Attributor/nofpclass-frem.ll
+++ b/llvm/test/Transforms/Attributor/nofpclass-frem.ll
@@ -396,7 +396,7 @@ define float @ret_frem_same_operands_nonan(float nofpclass(nan) %arg) #0 {
 }
 
 define float @ret_frem_no_neg_lhs(float nofpclass(ninf nsub nnorm) %arg0, float %arg1) #0 {
-; CHECK-LABEL: define float @ret_frem_no_neg_lhs
+; CHECK-LABEL: define nofpclass(ninf nsub nnorm) float @ret_frem_no_neg_lhs
 ; CHECK-SAME: (float nofpclass(ninf nsub nnorm) [[ARG0:%.*]], float [[ARG1:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[FREM:%.*]] = frem float [[ARG0]], [[ARG1]]
 ; CHECK-NEXT:    ret float [[FREM]]
@@ -426,7 +426,7 @@ define float @ret_frem_no_neg_nzero_rhs(float %arg0, float nofpclass(ninf nsub n
 }
 
 define float @ret_frem_no_neg(float nofpclass(ninf nsub nnorm) %arg0, float nofpclass(ninf nsub nnorm) %arg1) #0 {
-; CHECK-LABEL: define float @ret_frem_no_neg
+; CHECK-LABEL: define nofpclass(ninf nsub nnorm) float @ret_frem_no_neg
 ; CHECK-SAME: (float nofpclass(ninf nsub nnorm) [[ARG0:%.*]], float nofpclass(ninf nsub nnorm) [[ARG1:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[FREM:%.*]] = frem float [[ARG0]], [[ARG1]]
 ; CHECK-NEXT:    ret float [[FREM]]
@@ -446,7 +446,7 @@ define float @ret_frem_no_neg_nzero(float nofpclass(ninf nsub nnorm nzero) %arg0
 }
 
 define float @ret_frem_no_neg_rhs_no_nzero(float nofpclass(ninf nsub nnorm) %arg0, float nofpclass(ninf nsub nnorm nzero) %arg1) #0 {
-; CHECK-LABEL: define float @ret_frem_no_neg_rhs_no_nzero
+; CHECK-LABEL: define nofpclass(ninf nsub nnorm) float @ret_frem_no_neg_rhs_no_nzero
 ; CHECK-SAME: (float nofpclass(ninf nsub nnorm) [[ARG0:%.*]], float nofpclass(ninf nzero nsub nnorm) [[ARG1:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[FREM:%.*]] = frem float [[ARG0]], [[ARG1]]
 ; CHECK-NEXT:    ret float [[FREM]]
@@ -486,7 +486,7 @@ define float @ret_frem_no_pos_rhs(float %arg0, float nofpclass(pinf psub pnorm p
 }
 
 define float @ret_frem_no_pos_zero_lhs(float nofpclass(pinf psub pnorm) %arg0, float %arg1) #0 {
-; CHECK-LABEL: define float @ret_frem_no_pos_zero_lhs
+; CHECK-LABEL: define nofpclass(pinf psub pnorm) float @ret_frem_no_pos_zero_lhs
 ; CHECK-SAME: (float nofpclass(pinf psub pnorm) [[ARG0:%.*]], float [[ARG1:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:    [[FREM:%.*]] = frem float [[ARG0]], [[ARG1]]
 ; CHECK-NEXT:    ret float [[FREM]]


        


More information about the llvm-commits mailing list