forked from OSchip/llvm-project
[InstCombine] add tests for fcmp with -0.0; NFC
From IEEE754: "Comparisons shall ignore the sign of zero (so +0 = −0)." llvm-svn: 345752
This commit is contained in:
parent
3ca146d083
commit
5bcec66c55
|
@ -161,6 +161,7 @@ define <2 x i1> @ord_vec_with_undef(<2 x double> %x) {
|
|||
%f = fcmp ord <2 x double> %x, <double 0.0, double undef>
|
||||
ret <2 x i1> %f
|
||||
}
|
||||
|
||||
; TODO: This could be handled in InstSimplify.
|
||||
|
||||
define i1 @nnan_ops_to_fcmp_ord(float %x, float %y) {
|
||||
|
@ -185,3 +186,59 @@ define i1 @nnan_ops_to_fcmp_uno(float %x, float %y) {
|
|||
ret i1 %cmp
|
||||
}
|
||||
|
||||
; TODO: For any predicate/type/FMF, comparison to -0.0 is the same as comparison to +0.0.
|
||||
|
||||
define i1 @negative_zero_oeq(float %x) {
|
||||
; CHECK-LABEL: @negative_zero_oeq(
|
||||
; CHECK-NEXT: [[R:%.*]] = fcmp oeq float [[X:%.*]], -0.000000e+00
|
||||
; CHECK-NEXT: ret i1 [[R]]
|
||||
;
|
||||
%r = fcmp oeq float %x, -0.0
|
||||
ret i1 %r
|
||||
}
|
||||
|
||||
define i1 @negative_zero_oge(double %x) {
|
||||
; CHECK-LABEL: @negative_zero_oge(
|
||||
; CHECK-NEXT: [[R:%.*]] = fcmp nnan oge double [[X:%.*]], -0.000000e+00
|
||||
; CHECK-NEXT: ret i1 [[R]]
|
||||
;
|
||||
%r = fcmp nnan oge double %x, -0.0
|
||||
ret i1 %r
|
||||
}
|
||||
|
||||
define i1 @negative_zero_uge(half %x) {
|
||||
; CHECK-LABEL: @negative_zero_uge(
|
||||
; CHECK-NEXT: [[R:%.*]] = fcmp fast uge half [[X:%.*]], 0xH8000
|
||||
; CHECK-NEXT: ret i1 [[R]]
|
||||
;
|
||||
%r = fcmp fast uge half %x, -0.0
|
||||
ret i1 %r
|
||||
}
|
||||
|
||||
define <2 x i1> @negative_zero_olt_vec(<2 x float> %x) {
|
||||
; CHECK-LABEL: @negative_zero_olt_vec(
|
||||
; CHECK-NEXT: [[R:%.*]] = fcmp reassoc ninf olt <2 x float> [[X:%.*]], <float -0.000000e+00, float -0.000000e+00>
|
||||
; CHECK-NEXT: ret <2 x i1> [[R]]
|
||||
;
|
||||
%r = fcmp reassoc ninf olt <2 x float> %x, <float -0.0, float -0.0>
|
||||
ret <2 x i1> %r
|
||||
}
|
||||
|
||||
define <2 x i1> @negative_zero_une_vec_undef(<2 x double> %x) {
|
||||
; CHECK-LABEL: @negative_zero_une_vec_undef(
|
||||
; CHECK-NEXT: [[R:%.*]] = fcmp nnan une <2 x double> [[X:%.*]], <double -0.000000e+00, double undef>
|
||||
; CHECK-NEXT: ret <2 x i1> [[R]]
|
||||
;
|
||||
%r = fcmp nnan une <2 x double> %x, <double -0.0, double undef>
|
||||
ret <2 x i1> %r
|
||||
}
|
||||
|
||||
define <2 x i1> @negative_zero_ule_vec_mixed(<2 x float> %x) {
|
||||
; CHECK-LABEL: @negative_zero_ule_vec_mixed(
|
||||
; CHECK-NEXT: [[R:%.*]] = fcmp ule <2 x float> [[X:%.*]], <float 0.000000e+00, float -0.000000e+00>
|
||||
; CHECK-NEXT: ret <2 x i1> [[R]]
|
||||
;
|
||||
%r = fcmp ule <2 x float> %x, <float 0.0, float -0.0>
|
||||
ret <2 x i1> %r
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue