From: Sanjay Patel Date: Wed, 8 May 2019 17:53:18 +0000 (+0000) Subject: [InstSimplify] add tests for fcmp+minnum; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b5b5c473b0c1579dd7dcd8adbdcd1bbc4c8809c;p=llvm [InstSimplify] add tests for fcmp+minnum; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360275 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstSimplify/floating-point-compare.ll b/test/Transforms/InstSimplify/floating-point-compare.ll index 1a1afbe9133..982ff7b0bb1 100644 --- a/test/Transforms/InstSimplify/floating-point-compare.ll +++ b/test/Transforms/InstSimplify/floating-point-compare.ll @@ -179,6 +179,7 @@ declare float @llvm.sqrt.f32(float) declare double @llvm.powi.f64(double,i32) declare float @llvm.exp.f32(float) declare float @llvm.minnum.f32(float, float) +declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>) declare float @llvm.maxnum.f32(float, float) declare float @llvm.maximum.f32(float, float) declare double @llvm.exp2.f64(double) @@ -503,6 +504,162 @@ define i1 @maxnum_non_nan(float %x) { ret i1 %cmp } +; min(x, 0.5) == 1.0 --> false + +define i1 @minnum_oeq_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_oeq_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp oeq float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) > 1.0 --> false + +define i1 @minnum_ogt_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_ogt_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp ogt float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) >= 1.0 --> false + +define i1 @minnum_oge_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_oge_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp oge float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp oge float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) == 1.0 --> false + +define i1 @minnum_ueq_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_ueq_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp ueq float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp ueq float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) > 1.0 --> false + +define i1 @minnum_ugt_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_ugt_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp ugt float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp ugt float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) >= 1.0 --> false + +define <2 x i1> @minnum_uge_small_min_constant(<2 x float> %x) { +; CHECK-LABEL: @minnum_uge_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call <2 x float> @llvm.minnum.v2f32(<2 x float> [[X:%.*]], <2 x float> ) +; CHECK-NEXT: [[CMP:%.*]] = fcmp uge <2 x float> [[MIN]], +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %min = call <2 x float> @llvm.minnum.v2f32(<2 x float> %x, <2 x float> ) + %cmp = fcmp uge <2 x float> %min, + ret <2 x i1> %cmp +} + +; min(x, 0.5) < 1.0 --> true + +define <2 x i1> @minnum_olt_small_min_constant(<2 x float> %x) { +; CHECK-LABEL: @minnum_olt_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call <2 x float> @llvm.minnum.v2f32(<2 x float> [[X:%.*]], <2 x float> ) +; CHECK-NEXT: [[CMP:%.*]] = fcmp olt <2 x float> [[MIN]], +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %min = call <2 x float> @llvm.minnum.v2f32(<2 x float> %x, <2 x float> ) + %cmp = fcmp olt <2 x float> %min, + ret <2 x i1> %cmp +} + +; min(x, 0.5) <= 1.0 --> true + +define i1 @minnum_ole_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_ole_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp ole float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp ole float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) != 1.0 --> true + +define i1 @minnum_one_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_one_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp one float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp one float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) < 1.0 --> true + +define i1 @minnum_ult_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_ult_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp ult float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp ult float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) <= 1.0 --> true + +define i1 @minnum_ule_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_ule_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp ule float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp ule float %min, 1.0 + ret i1 %cmp +} + +; min(x, 0.5) != 1.0 --> true + +define i1 @minnum_une_small_min_constant(float %x) { +; CHECK-LABEL: @minnum_une_small_min_constant( +; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 5.000000e-01) +; CHECK-NEXT: [[CMP:%.*]] = fcmp une float [[MIN]], 1.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %min = call float @llvm.minnum.f32(float %x, float 0.5) + %cmp = fcmp une float %min, 1.0 + ret i1 %cmp +} + define i1 @known_positive_olt_with_negative_constant(double %a) { ; CHECK-LABEL: @known_positive_olt_with_negative_constant( ; CHECK-NEXT: ret i1 false