[InstCombine] add/adjust test for NaN checks; NFC

llvm-svn: 356383
This commit is contained in:
Sanjay Patel 2019-03-18 17:37:05 +00:00
parent 55c921f4bf
commit 08b5e68ef6
2 changed files with 84 additions and 22 deletions

View File

@ -23,23 +23,38 @@ define <2 x i1> @PR1738_vec_undef(<2 x double> %x, <2 x double> %y) {
ret <2 x i1> %or
}
define i1 @PR41069(float %a, float %b, float %c, float %d) {
define i1 @PR41069(i1 %z, float %c, float %d) {
; CHECK-LABEL: @PR41069(
; CHECK-NEXT: [[ORD1:%.*]] = fcmp ord float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT: [[ORD2:%.*]] = fcmp ord float [[C:%.*]], 0.000000e+00
; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD1]], [[ORD2]]
; CHECK-NEXT: [[ORD3:%.*]] = fcmp ord float [[D:%.*]], 0.000000e+00
; CHECK-NEXT: [[R:%.*]] = and i1 [[AND]], [[ORD3]]
; CHECK-NEXT: [[ORD1:%.*]] = fcmp ord float [[C:%.*]], 0.000000e+00
; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD1]], [[Z:%.*]]
; CHECK-NEXT: [[ORD2:%.*]] = fcmp ord float [[D:%.*]], 0.000000e+00
; CHECK-NEXT: [[R:%.*]] = and i1 [[AND]], [[ORD2]]
; CHECK-NEXT: ret i1 [[R]]
;
%ord1 = fcmp ord float %a, %b
%ord2 = fcmp ord float %c, 0.0
%and = and i1 %ord1, %ord2
%ord3 = fcmp ord float %d, 0.0
%r = and i1 %and, %ord3
%ord1 = fcmp ord float %c, 0.0
%and = and i1 %ord1, %z
%ord2 = fcmp ord float %d, 0.0
%r = and i1 %and, %ord2
ret i1 %r
}
define i1 @PR41069_commute(i1 %z, float %c, float %d) {
; CHECK-LABEL: @PR41069_commute(
; CHECK-NEXT: [[ORD1:%.*]] = fcmp ord float [[C:%.*]], 0.000000e+00
; CHECK-NEXT: [[AND:%.*]] = and i1 [[ORD1]], [[Z:%.*]]
; CHECK-NEXT: [[ORD2:%.*]] = fcmp ord float [[D:%.*]], 0.000000e+00
; CHECK-NEXT: [[R:%.*]] = and i1 [[ORD2]], [[AND]]
; CHECK-NEXT: ret i1 [[R]]
;
%ord1 = fcmp ord float %c, 0.0
%and = and i1 %ord1, %z
%ord2 = fcmp ord float %d, 0.0
%r = and i1 %ord2, %and
ret i1 %r
}
; Commute differently and make sure vectors work.
define <2 x i1> @PR41069_vec(<2 x double> %a, <2 x double> %b, <2 x double> %c, <2 x double> %d) {
; CHECK-LABEL: @PR41069_vec(
; CHECK-NEXT: [[ORD1:%.*]] = fcmp ord <2 x double> [[A:%.*]], [[B:%.*]]
@ -57,6 +72,23 @@ define <2 x i1> @PR41069_vec(<2 x double> %a, <2 x double> %b, <2 x double> %c,
ret <2 x i1> %r
}
define <2 x i1> @PR41069_vec_commute(<2 x double> %a, <2 x double> %b, <2 x double> %c, <2 x double> %d) {
; CHECK-LABEL: @PR41069_vec_commute(
; CHECK-NEXT: [[ORD1:%.*]] = fcmp ord <2 x double> [[A:%.*]], [[B:%.*]]
; CHECK-NEXT: [[ORD2:%.*]] = fcmp ord <2 x double> [[C:%.*]], <double 0.000000e+00, double undef>
; CHECK-NEXT: [[AND:%.*]] = and <2 x i1> [[ORD1]], [[ORD2]]
; CHECK-NEXT: [[ORD3:%.*]] = fcmp ord <2 x double> [[D:%.*]], zeroinitializer
; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[ORD3]], [[AND]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%ord1 = fcmp ord <2 x double> %a, %b
%ord2 = fcmp ord <2 x double> %c, <double 0.0, double undef>
%and = and <2 x i1> %ord1, %ord2
%ord3 = fcmp ord <2 x double> %d, zeroinitializer
%r = and <2 x i1> %ord3, %and
ret <2 x i1> %r
}
define i1 @PR15737(float %a, double %b) {
; CHECK-LABEL: @PR15737(
; CHECK-NEXT: [[CMP:%.*]] = fcmp ord float [[A:%.*]], 0.000000e+00

View File

@ -40,20 +40,50 @@ define i1 @PR41069(double %a, double %b, double %c, double %d) {
ret i1 %r
}
define <2 x i1> @PR41069_vec(<2 x float> %a, <2 x float> %b, <2 x float> %c, <2 x float> %d) {
define i1 @PR41069_commute(double %a, double %b, double %c, double %d) {
; CHECK-LABEL: @PR41069_commute(
; CHECK-NEXT: [[UNO1:%.*]] = fcmp uno double [[A:%.*]], [[B:%.*]]
; CHECK-NEXT: [[UNO2:%.*]] = fcmp uno double [[C:%.*]], 0.000000e+00
; CHECK-NEXT: [[OR:%.*]] = or i1 [[UNO1]], [[UNO2]]
; CHECK-NEXT: [[UNO3:%.*]] = fcmp uno double [[D:%.*]], 0.000000e+00
; CHECK-NEXT: [[R:%.*]] = or i1 [[UNO3]], [[OR]]
; CHECK-NEXT: ret i1 [[R]]
;
%uno1 = fcmp uno double %a, %b
%uno2 = fcmp uno double %c, 0.0
%or = or i1 %uno1, %uno2
%uno3 = fcmp uno double %d, 0.0
%r = or i1 %uno3, %or
ret i1 %r
}
define <2 x i1> @PR41069_vec(<2 x i1> %z, <2 x float> %c, <2 x float> %d) {
; CHECK-LABEL: @PR41069_vec(
; CHECK-NEXT: [[UNO1:%.*]] = fcmp uno <2 x float> [[A:%.*]], [[B:%.*]]
; CHECK-NEXT: [[UNO2:%.*]] = fcmp uno <2 x float> [[C:%.*]], zeroinitializer
; CHECK-NEXT: [[OR:%.*]] = or <2 x i1> [[UNO1]], [[UNO2]]
; CHECK-NEXT: [[UNO3:%.*]] = fcmp uno <2 x float> [[D:%.*]], <float 0.000000e+00, float undef>
; CHECK-NEXT: [[R:%.*]] = or <2 x i1> [[OR]], [[UNO3]]
; CHECK-NEXT: [[UNO1:%.*]] = fcmp uno <2 x float> [[C:%.*]], zeroinitializer
; CHECK-NEXT: [[OR:%.*]] = or <2 x i1> [[UNO1]], [[Z:%.*]]
; CHECK-NEXT: [[UNO2:%.*]] = fcmp uno <2 x float> [[D:%.*]], <float 0.000000e+00, float undef>
; CHECK-NEXT: [[R:%.*]] = or <2 x i1> [[OR]], [[UNO2]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%uno1 = fcmp uno <2 x float> %a, %b
%uno2 = fcmp uno <2 x float> %c, zeroinitializer
%or = or <2 x i1> %uno1, %uno2
%uno3 = fcmp uno <2 x float> %d, <float 0.0, float undef>
%r = or <2 x i1> %or, %uno3
%uno1 = fcmp uno <2 x float> %c, zeroinitializer
%or = or <2 x i1> %uno1, %z
%uno2 = fcmp uno <2 x float> %d, <float 0.0, float undef>
%r = or <2 x i1> %or, %uno2
ret <2 x i1> %r
}
define <2 x i1> @PR41069_vec_commute(<2 x i1> %z, <2 x float> %c, <2 x float> %d) {
; CHECK-LABEL: @PR41069_vec_commute(
; CHECK-NEXT: [[UNO1:%.*]] = fcmp uno <2 x float> [[C:%.*]], zeroinitializer
; CHECK-NEXT: [[OR:%.*]] = or <2 x i1> [[UNO1]], [[Z:%.*]]
; CHECK-NEXT: [[UNO2:%.*]] = fcmp uno <2 x float> [[D:%.*]], <float 0.000000e+00, float undef>
; CHECK-NEXT: [[R:%.*]] = or <2 x i1> [[UNO2]], [[OR]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%uno1 = fcmp uno <2 x float> %c, zeroinitializer
%or = or <2 x i1> %uno1, %z
%uno2 = fcmp uno <2 x float> %d, <float 0.0, float undef>
%r = or <2 x i1> %uno2, %or
ret <2 x i1> %r
}