From: Sanjay Patel Date: Mon, 18 Mar 2019 17:37:05 +0000 (+0000) Subject: [InstCombine] add/adjust test for NaN checks; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=edbd5597b3a97310a7a3cd2323e1fe6170096332;p=llvm [InstCombine] add/adjust test for NaN checks; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356383 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/and-fcmp.ll b/test/Transforms/InstCombine/and-fcmp.ll index 56954dfb2e2..c53de793191 100644 --- a/test/Transforms/InstCombine/and-fcmp.ll +++ b/test/Transforms/InstCombine/and-fcmp.ll @@ -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:%.*]], +; 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, + %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 diff --git a/test/Transforms/InstCombine/or-fcmp.ll b/test/Transforms/InstCombine/or-fcmp.ll index 38872160737..eee31d5a7d5 100644 --- a/test/Transforms/InstCombine/or-fcmp.ll +++ b/test/Transforms/InstCombine/or-fcmp.ll @@ -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:%.*]], -; 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:%.*]], +; CHECK-NEXT: [[R:%.*]] = or <2 x i1> [[OR]], [[UNO2]] +; 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, + %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:%.*]], +; CHECK-NEXT: [[R:%.*]] = or <2 x i1> [[UNO2]], [[OR]] ; 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, - %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, + %r = or <2 x i1> %uno2, %or ret <2 x i1> %r }