[llvm] 9cc669d - [InstCombine][InstSimplify] add tests for sign of maxnum; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 05:08:27 PDT 2020


Author: Sanjay Patel
Date: 2020-07-14T08:08:09-04:00
New Revision: 9cc669d22d8641e9d359d871ac7761a121c9caf0

URL: https://github.com/llvm/llvm-project/commit/9cc669d22d8641e9d359d871ac7761a121c9caf0
DIFF: https://github.com/llvm/llvm-project/commit/9cc669d22d8641e9d359d871ac7761a121c9caf0.diff

LOG: [InstCombine][InstSimplify] add tests for sign of maxnum; NFC

More coverage for D83601.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/copysign.ll
    llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
    llvm/test/Transforms/InstSimplify/floating-point-compare.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/copysign.ll b/llvm/test/Transforms/InstCombine/copysign.ll
index f7e387fb60d0..2e0063e86356 100644
--- a/llvm/test/Transforms/InstCombine/copysign.ll
+++ b/llvm/test/Transforms/InstCombine/copysign.ll
@@ -3,6 +3,7 @@
 
 declare float @llvm.fabs.f32(float)
 declare float @llvm.copysign.f32(float, float)
+declare float @llvm.maxnum.f32(float, float)
 declare <3 x double> @llvm.copysign.v3f64(<3 x double>, <3 x double>)
 
 define float @positive_sign_arg(float %x) {
@@ -63,6 +64,18 @@ define <3 x double> @known_positive_sign_arg_vec(<3 x double> %x, <3 x i32> %y)
   ret <3 x double> %r
 }
 
+; FIXME: maxnum(-0.0, 0.0) can return -0.0.
+
+define float @not_known_positive_sign_arg(float %x, float %y) {
+; CHECK-LABEL: @not_known_positive_sign_arg(
+; CHECK-NEXT:    [[TMP1:%.*]] = call ninf float @llvm.fabs.f32(float [[Y:%.*]])
+; CHECK-NEXT:    ret float [[TMP1]]
+;
+  %max = call float @llvm.maxnum.f32(float %x, float 0.0)
+  %r = call ninf float @llvm.copysign.f32(float %y, float %max)
+  ret float %r
+}
+
 ; The magnitude operand of the 1st copysign is irrelevant.
 ; copysign(x, copysign(y, z)) --> copysign(x, z)
 

diff  --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
index 653b730fac36..dca25a3791f5 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
@@ -1383,3 +1383,13 @@ define float @maxnum_with_negzero_op_commute(float %a) {
   %fabs = call float @llvm.fabs.f32(float %max)
   ret float %fabs
 }
+
+define float @maxnum_with_pos_one_op(float %a) {
+; CHECK-LABEL: @maxnum_with_pos_one_op(
+; CHECK-NEXT:    [[MAX:%.*]] = call float @llvm.maxnum.f32(float [[A:%.*]], float 1.000000e+00)
+; CHECK-NEXT:    ret float [[MAX]]
+;
+  %max = call float @llvm.maxnum.f32(float %a, float 1.0)
+  %fabs = call float @llvm.fabs.f32(float %max)
+  ret float %fabs
+}

diff  --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index 7de0664b041b..6f3f738b6d3e 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -212,6 +212,15 @@ define i1 @orderedLessZero_fdiv(float %x) {
   ret i1 %uge
 }
 
+define i1 @orderedLessZero_maxnum(float %x) {
+; CHECK-LABEL: @orderedLessZero_maxnum(
+; CHECK-NEXT:    ret i1 true
+;
+  %d = call float @llvm.maxnum.f32(float %x, float 0.0)
+  %uge = fcmp uge float %d, 0.0
+  ret i1 %uge
+}
+
 define i1 @orderedLessZeroExpExt(float) {
 ; CHECK-LABEL: @orderedLessZeroExpExt(
 ; CHECK-NEXT:    ret i1 true


        


More information about the llvm-commits mailing list