forked from OSchip/llvm-project
[InstSimplify] Add test cases for removal of vector fabs on known positive.
llvm-svn: 326050
This commit is contained in:
parent
2b8f051aaa
commit
aee341ef28
|
@ -113,6 +113,7 @@ define float @PR22688(float %x) {
|
|||
}
|
||||
|
||||
declare float @llvm.fabs.f32(float)
|
||||
declare <2 x float> @llvm.fabs.v2f32(<2 x float>)
|
||||
declare float @llvm.sqrt.f32(float)
|
||||
|
||||
define float @fabs_select_positive_constants(i32 %c) {
|
||||
|
@ -127,6 +128,19 @@ define float @fabs_select_positive_constants(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_positive_constants_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_positive_constants_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float> <float 2.000000e+00, float 2.000000e+00>
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float 1.0, float 1.0>, <2 x float> <float 2.0, float 2.0>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_constant_variable(i32 %c, float %x) {
|
||||
; CHECK-LABEL: @fabs_select_constant_variable(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -140,6 +154,19 @@ define float @fabs_select_constant_variable(i32 %c, float %x) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_constant_variable_vector(i32 %c, <2 x float> %x) {
|
||||
; CHECK-LABEL: @fabs_select_constant_variable_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float 1.000000e+00, float 1.000000e+00>, <2 x float> [[X:%.*]]
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float 1.0, float 1.0>, <2 x float> %x
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_neg0_pos0(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_neg0_pos0(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -153,6 +180,19 @@ define float @fabs_select_neg0_pos0(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_neg0_pos0_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_neg0_pos0_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, <2 x float> zeroinitializer
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float -0.0, float -0.0>, <2 x float> <float 0.0, float 0.0>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_neg0_neg1(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_neg0_neg1(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -166,6 +206,19 @@ define float @fabs_select_neg0_neg1(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_neg0_neg1_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_neg0_neg1_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, <2 x float> <float -1.000000e+00, float -1.000000e+00>
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float -0.0, float -0.0>, <2 x float> <float -1.0, float -1.0>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_nan_nan(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_nan_nan(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -178,6 +231,19 @@ define float @fabs_select_nan_nan(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_nan_nan_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_nan_nan_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>, <2 x float> <float 0x7FF8000100000000, float 0x7FF8000100000000>
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>, <2 x float> <float 0x7FF8000100000000, float 0x7FF8000100000000>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_negnan_nan(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_nan(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -191,6 +257,19 @@ define float @fabs_select_negnan_nan(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_negnan_nan_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_nan_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_negnan_negnan(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_negnan(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -204,6 +283,19 @@ define float @fabs_select_negnan_negnan(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_negnan_negnan_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_negnan_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> <float 0x7FF8000100000000, float 0x7FF8000100000000>
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> <float 0x7FF8000100000000, float 0x7FF8000100000000>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_negnan_negzero(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_negzero(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -217,6 +309,19 @@ define float @fabs_select_negnan_negzero(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_negnan_negzero_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_negzero_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> <float -0.000000e+00, float -0.000000e+00>
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> <float -0.0, float -0.0>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
define float @fabs_select_negnan_zero(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_zero(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
|
@ -230,6 +335,19 @@ define float @fabs_select_negnan_zero(i32 %c) {
|
|||
ret float %fabs
|
||||
}
|
||||
|
||||
define <2 x float> @fabs_select_negnan_zero_vector(i32 %c) {
|
||||
; CHECK-LABEL: @fabs_select_negnan_zero_vector(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[C:%.*]], 0
|
||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> zeroinitializer
|
||||
; CHECK-NEXT: [[FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[SELECT]])
|
||||
; CHECK-NEXT: ret <2 x float> [[FABS]]
|
||||
;
|
||||
%cmp = icmp eq i32 %c, 0
|
||||
%select = select i1 %cmp, <2 x float> <float 0xFFF8000000000000, float 0xFFF8000000000000>, <2 x float> <float 0.0, float 0.0>
|
||||
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %select)
|
||||
ret <2 x float> %fabs
|
||||
}
|
||||
|
||||
; The fabs can't be eliminated because llvm.sqrt.f32 may return -0 or NaN with
|
||||
; an arbitrary sign bit.
|
||||
define float @fabs_sqrt(float %a) {
|
||||
|
|
Loading…
Reference in New Issue