[InstCombine] add tests for min/max FP intrinsics with FMF (PR45478); NFC

https://bugs.llvm.org/show_bug.cgi?id=45478
This commit is contained in:
Sanjay Patel 2020-04-22 08:42:44 -04:00
parent 48ac4e6938
commit 6f19f0fb9a
4 changed files with 110 additions and 24 deletions

View File

@ -147,8 +147,9 @@ define float @maximum_f32_val_nan(float %x) {
define float @maximum_f32_1_maximum_val_p0(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_val_p0(
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maximum.f32(float %x, float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @llvm.maximum.f32(float %x, float 0.0)
%z = call float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
@ -156,26 +157,49 @@ define float @maximum_f32_1_maximum_val_p0(float %x) {
define float @maximum_f32_1_maximum_p0_val_fast(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fast(
; CHECK-NEXT: [[RES:%.*]] = call fast float @llvm.maximum.f32(float %x, float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @llvm.maximum.f32(float 0.0, float %x)
%z = call fast float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define float @maximum_f32_1_maximum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_nnan_ninf(
; CHECK-NEXT: [[RES:%.*]] = call nnan ninf float @llvm.maximum.f32(float %x, float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
%y = call float @llvm.maximum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.maximum.f32(float %y, float 1.0)
define float @maximum_f32_1_maximum_p0_val_fmf1(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fmf1(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf arcp float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call arcp nnan float @llvm.maximum.f32(float 0.0, float %x)
%z = call arcp nnan ninf float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define float @maximum_f32_1_maximum_p0_val_fmf2(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fmf2(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call arcp nnan ninf float @llvm.maximum.f32(float 0.0, float %x)
%z = call nnan float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define float @maximum_f32_1_maximum_p0_val_fmf3(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val_fmf3(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf arcp float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call nnan ninf float @llvm.maximum.f32(float 0.0, float %x)
%z = call arcp nnan ninf float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
}
define float @maximum_f32_p0_maximum_val_n0(float %x) {
; CHECK-LABEL: @maximum_f32_p0_maximum_val_n0(
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maximum.f32(float %x, float 0.000000e+00)
; CHECK-NEXT: ret float [[RES]]
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @llvm.maximum.f32(float %x, float -0.0)
%z = call float @llvm.maximum.f32(float %y, float 0.0)
ret float %z
@ -183,8 +207,9 @@ define float @maximum_f32_p0_maximum_val_n0(float %x) {
define float @maximum_f32_1_maximum_p0_val(float %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_p0_val(
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.maximum.f32(float %x, float 1.000000e+00)
; CHECK-NEXT: ret float [[RES]]
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @llvm.maximum.f32(float 0.0, float %x)
%z = call float @llvm.maximum.f32(float %y, float 1.0)
ret float %z
@ -192,8 +217,9 @@ define float @maximum_f32_1_maximum_p0_val(float %x) {
define <2 x float> @maximum_f32_1_maximum_val_p0_val_v2f32(<2 x float> %x) {
; CHECK-LABEL: @maximum_f32_1_maximum_val_p0_val_v2f32(
; CHECK-NEXT: [[RES:%.*]] = call <2 x float> @llvm.maximum.v2f32(<2 x float> %x, <2 x float> <float 1.000000e+00, float 1.000000e+00>)
; CHECK-NEXT: ret <2 x float> [[RES]]
; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.maximum.v2f32(<2 x float> [[X:%.*]], <2 x float> <float 1.000000e+00, float 1.000000e+00>)
; CHECK-NEXT: ret <2 x float> [[TMP1]]
;
%y = call <2 x float> @llvm.maximum.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
%z = call <2 x float> @llvm.maximum.v2f32(<2 x float> %y, <2 x float><float 1.0, float 1.0>)
ret <2 x float> %z

View File

@ -165,16 +165,36 @@ define float @maxnum_f32_1_maxnum_p0_val_fast(float %x) {
ret float %z
}
define float @maxnum_f32_1_maxnum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @maxnum_f32_1_maxnum_p0_val_nnan_ninf(
define float @minnum_f32_1_maxnum_p0_val_fmf1(float %x) {
; CHECK-LABEL: @minnum_f32_1_maxnum_p0_val_fmf1(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @llvm.maxnum.f32(float 0.0, float %x)
%y = call nnan float @llvm.maxnum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.maxnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_1_maxnum_p0_val_fmf2(float %x) {
; CHECK-LABEL: @minnum_f32_1_maxnum_p0_val_fmf2(
; CHECK-NEXT: [[TMP1:%.*]] = call ninf float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call nnan ninf float @llvm.maxnum.f32(float 0.0, float %x)
%z = call ninf float @llvm.maxnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_1_maxnum_p0_val_fmf3(float %x) {
; CHECK-LABEL: @minnum_f32_1_maxnum_p0_val_fmf3(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.maxnum.f32(float [[X:%.*]], float 1.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call ninf nnan float @llvm.maxnum.f32(float 0.0, float %x)
%z = call ninf nnan float @llvm.maxnum.f32(float %y, float 1.0)
ret float %z
}
define float @maxnum_f32_p0_maxnum_val_n0(float %x) {
; CHECK-LABEL: @maxnum_f32_p0_maxnum_val_n0(
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 0.000000e+00)

View File

@ -167,8 +167,8 @@ define float @minimum_f32_1_minimum_p0_val_fast(float %x) {
ret float %z
}
define float @minimum_f32_1_minimum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_nnan_ninf(
define float @minimum_f32_1_minimum_p0_val_fmf1(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fmf1(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.minimum.f32(float [[X:%.*]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
@ -177,6 +177,26 @@ define float @minimum_f32_1_minimum_p0_val_nnan_ninf(float %x) {
ret float %z
}
define float @minimum_f32_1_minimum_p0_val_fmf2(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fmf2(
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call nnan ninf float @llvm.minimum.f32(float 0.0, float %x)
%z = call float @llvm.minimum.f32(float %y, float 1.0)
ret float %z
}
define float @minimum_f32_1_minimum_p0_val_fmf3(float %x) {
; CHECK-LABEL: @minimum_f32_1_minimum_p0_val_fmf3(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.minimum.f32(float [[X:%.*]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call nnan ninf float @llvm.minimum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.minimum.f32(float %y, float 1.0)
ret float %z
}
define float @minimum_f32_p0_minimum_val_n0(float %x) {
; CHECK-LABEL: @minimum_f32_p0_minimum_val_n0(
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float -0.000000e+00)

View File

@ -167,16 +167,36 @@ define float @minnum_f32_1_minnum_p0_val_fast(float %x) {
ret float %z
}
define float @minnum_f32_1_minnum_p0_val_nnan_ninf(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_nnan_ninf(
define float @minnum_f32_1_minnum_p0_val_fmf1(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fmf1(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call float @llvm.minnum.f32(float 0.0, float %x)
%y = call nsz nnan float @llvm.minnum.f32(float 0.0, float %x)
%z = call nnan ninf float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_1_minnum_p0_val_fmf2(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fmf2(
; CHECK-NEXT: [[TMP1:%.*]] = call ninf nsz float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call nnan ninf float @llvm.minnum.f32(float 0.0, float %x)
%z = call nsz ninf float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_1_minnum_p0_val_fmf3(float %x) {
; CHECK-LABEL: @minnum_f32_1_minnum_p0_val_fmf3(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf nsz float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)
; CHECK-NEXT: ret float [[TMP1]]
;
%y = call nsz ninf nnan float @llvm.minnum.f32(float 0.0, float %x)
%z = call nsz ninf nnan float @llvm.minnum.f32(float %y, float 1.0)
ret float %z
}
define float @minnum_f32_p0_minnum_val_n0(float %x) {
; CHECK-LABEL: @minnum_f32_p0_minnum_val_n0(
; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0.000000e+00)