X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FTransforms%2FInstCombine%2Ffast-math.ll;h=2ee4b0f2c381217f5ae1e72e9a2fa6d7512f044e;hb=578c74e35da692fe0435491e1acb245f37bf6930;hp=47f1ec480468d97057a66329bba2cffa34b2e59a;hpb=a0c9939873c404f272b3e0abb102c335146764fe;p=oota-llvm.git diff --git a/test/Transforms/InstCombine/fast-math.ll b/test/Transforms/InstCombine/fast-math.ll index 47f1ec48046..2ee4b0f2c38 100644 --- a/test/Transforms/InstCombine/fast-math.ll +++ b/test/Transforms/InstCombine/fast-math.ll @@ -6,14 +6,14 @@ define float @fold(float %a) { %mul = fmul fast float %a, 0x3FF3333340000000 %mul1 = fmul fast float %mul, 0x4002666660000000 ret float %mul1 -; CHECK: @fold +; CHECK-LABEL: @fold( ; CHECK: fmul fast float %a, 0x4006147AE0000000 } ; Same testing-case as the one used in fold() except that the operators have ; fixed FP mode. define float @notfold(float %a) { -; CHECK: @notfold +; CHECK-LABEL: @notfold( ; CHECK: %mul = fmul fast float %a, 0x3FF3333340000000 %mul = fmul fast float %a, 0x3FF3333340000000 %mul1 = fmul float %mul, 0x4002666660000000 @@ -21,7 +21,7 @@ define float @notfold(float %a) { } define float @fold2(float %a) { -; CHECK: @fold2 +; CHECK-LABEL: @fold2( ; CHECK: fmul fast float %a, 0x4006147AE0000000 %mul = fmul float %a, 0x3FF3333340000000 %mul1 = fmul fast float %mul, 0x4002666660000000 @@ -33,7 +33,7 @@ define double @fold3(double %f1) { %t1 = fmul fast double 2.000000e+00, %f1 %t2 = fadd fast double %f1, %t1 ret double %t2 -; CHECK: @fold3 +; CHECK-LABEL: @fold3( ; CHECK: fmul fast double %f1, 3.000000e+00 } @@ -43,7 +43,7 @@ define float @fold4(float %f1, float %f2) { %sub1 = fsub float 5.000000e+00, %f2 %add = fadd fast float %sub, %sub1 ret float %add -; CHECK: @fold4 +; CHECK-LABEL: @fold4( ; CHECK: %1 = fadd fast float %f1, %f2 ; CHECK: fsub fast float 9.000000e+00, %1 } @@ -53,7 +53,7 @@ define float @fold5(float %f1, float %f2) { %add = fadd float %f1, 4.000000e+00 %add1 = fadd fast float %add, 5.000000e+00 ret float %add1 -; CHECK: @fold5 +; CHECK-LABEL: @fold5( ; CHECK: fadd fast float %f1, 9.000000e+00 } @@ -62,7 +62,7 @@ define float @fold6(float %f1) { %t1 = fadd fast float %f1, %f1 %t2 = fadd fast float %f1, %t1 ret float %t2 -; CHECK: @fold6 +; CHECK-LABEL: @fold6( ; CHECK: fmul fast float %f1, 3.000000e+00 } @@ -72,7 +72,7 @@ define float @fold7(float %f1) { %t2 = fadd fast float %f1, %f1 %t3 = fadd fast float %t1, %t2 ret float %t3 -; CHECK: @fold7 +; CHECK-LABEL: @fold7( ; CHECK: fmul fast float %f1, 7.000000e+00 } @@ -92,7 +92,7 @@ define float @fold9(float %f1, float %f2) { %t3 = fsub fast float %f1, %t1 ret float %t3 -; CHECK: @fold9 +; CHECK-LABEL: @fold9( ; CHECK: fsub fast float 0.000000e+00, %f2 } @@ -106,7 +106,7 @@ define float @fold10(float %f1, float %f2) { %t2 = fsub fast float %f2, 3.000000e+00 %t3 = fadd fast float %t1, %t2 ret float %t3 -; CHECK: @fold10 +; CHECK-LABEL: @fold10( ; CHECK: %t3 = fadd fast float %t2, -1.000000e+00 ; CHECK: ret float %t3 } @@ -117,7 +117,7 @@ define float @fail1(float %f1, float %f2) { %add = fadd fast float %conv3, %conv3 %add2 = fadd fast float %add, %conv3 ret float %add2 -; CHECK: @fail1 +; CHECK-LABEL: @fail1( ; CHECK: ret } @@ -126,10 +126,56 @@ define double @fail2(double %f1, double %f2) { %t2 = fadd fast double %f1, %f2 %t3 = fsub fast double %t1, %t2 ret double %t3 -; CHECK: @fail2 +; CHECK-LABEL: @fail2( ; CHECK: ret } +; c1 * x - x => (c1 - 1.0) * x +define float @fold13(float %x) { + %mul = fmul fast float %x, 7.000000e+00 + %sub = fsub fast float %mul, %x + ret float %sub +; CHECK: fold13 +; CHECK: fmul fast float %x, 6.000000e+00 +; CHECK: ret +} + +; -x + y => y - x +define float @fold14(float %x, float %y) { + %neg = fsub fast float -0.0, %x + %add = fadd fast float %neg, %y + ret float %add +; CHECK: fold14 +; CHECK: fsub fast float %y, %x +; CHECK: ret +} + +; x + -y => x - y +define float @fold15(float %x, float %y) { + %neg = fsub fast float -0.0, %y + %add = fadd fast float %x, %neg + ret float %add +; CHECK: fold15 +; CHECK: fsub fast float %x, %y +; CHECK: ret +} + +; (select X+Y, X-Y) => X + (select Y, -Y) +define float @fold16(float %x, float %y) { + %cmp = fcmp ogt float %x, %y + %plus = fadd fast float %x, %y + %minus = fsub fast float %x, %y + %r = select i1 %cmp, float %plus, float %minus + ret float %r +; CHECK: fold16 +; CHECK: fsub fast float +; CHECK: select +; CHECK: fadd fast float +; CHECK: ret +} + + + ; ========================================================================= ; ; Testing-cases about fmul begin @@ -142,7 +188,7 @@ define float @fmul_distribute1(float %f1) { %t2 = fadd float %t1, 2.0e+3 %t3 = fmul fast float %t2, 5.0e+3 ret float %t3 -; CHECK: @fmul_distribute1 +; CHECK-LABEL: @fmul_distribute1( ; CHECK: %1 = fmul fast float %f1, 3.000000e+07 ; CHECK: %t3 = fadd fast float %1, 1.000000e+07 } @@ -155,7 +201,7 @@ define double @fmul_distribute2(double %f1, double %f2) { %t3 = fmul fast double %t2, 0x10000000000000 ret double %t3 -; CHECK: @fmul_distribute2 +; CHECK-LABEL: @fmul_distribute2( ; CHECK: %1 = fdiv fast double %f1, 0x7FE8000000000000 ; CHECK: fadd fast double %1, 0x69000000000000 } @@ -168,7 +214,7 @@ define double @fmul_distribute3(double %f1) { %t3 = fmul fast double %t2, 0x10000000000000 ret double %t3 -; CHECK: @fmul_distribute3 +; CHECK-LABEL: @fmul_distribute3( ; CHECK: fmul fast double %t2, 0x10000000000000 } @@ -178,7 +224,7 @@ define float @fmul_distribute4(float %f1) { %t2 = fsub float 2.0e+3, %t1 %t3 = fmul fast float %t2, 5.0e+3 ret float %t3 -; CHECK: @fmul_distribute4 +; CHECK-LABEL: @fmul_distribute4( ; CHECK: %1 = fmul fast float %f1, 3.000000e+07 ; CHECK: %t3 = fsub fast float 1.000000e+07, %1 } @@ -188,19 +234,39 @@ define float @fmul2(float %f1) { %t1 = fdiv float 2.0e+3, %f1 %t3 = fmul fast float %t1, 6.0e+3 ret float %t3 -; CHECK: @fmul2 +; CHECK-LABEL: @fmul2( ; CHECK: fdiv fast float 1.200000e+07, %f1 } +; X/C1 * C2 => X * (C2/C1) is disabled if X/C1 has multiple uses +@fmul2_external = external global float +define float @fmul2_disable(float %f1) { + %div = fdiv fast float 1.000000e+00, %f1 + store float %div, float* @fmul2_external + %mul = fmul fast float %div, 2.000000e+00 + ret float %mul +; CHECK-LABEL: @fmul2_disable +; CHECK: store +; CHECK: fmul fast +} + ; X/C1 * C2 => X * (C2/C1) (if C2/C1 is normal Fp) define float @fmul3(float %f1, float %f2) { %t1 = fdiv float %f1, 2.0e+3 %t3 = fmul fast float %t1, 6.0e+3 ret float %t3 -; CHECK: @fmul3 +; CHECK-LABEL: @fmul3( ; CHECK: fmul fast float %f1, 3.000000e+00 } +define <4 x float> @fmul3_vec(<4 x float> %f1, <4 x float> %f2) { + %t1 = fdiv <4 x float> %f1, + %t3 = fmul fast <4 x float> %t1, + ret <4 x float> %t3 +; CHECK-LABEL: @fmul3_vec( +; CHECK: fmul fast <4 x float> %f1, +} + ; Rule "X/C1 * C2 => X * (C2/C1) is not applicable if C2/C1 is either a special ; value of a denormal. The 0x3810000000000000 here take value FLT_MIN ; @@ -208,7 +274,7 @@ define float @fmul4(float %f1, float %f2) { %t1 = fdiv float %f1, 2.0e+3 %t3 = fmul fast float %t1, 0x3810000000000000 ret float %t3 -; CHECK: @fmul4 +; CHECK-LABEL: @fmul4( ; CHECK: fmul fast float %t1, 0x3810000000000000 } @@ -219,7 +285,7 @@ define float @fmul5(float %f1, float %f2) { %t1 = fdiv float %f1, 3.0e+0 %t3 = fmul fast float %t1, 0x3810000000000000 ret float %t3 -; CHECK: @fmul5 +; CHECK-LABEL: @fmul5( ; CHECK: fdiv fast float %f1, 0x47E8000000000000 } @@ -228,7 +294,7 @@ define float @fmul6(float %f1, float %f2) { %mul = fmul float %f1, %f2 %mul1 = fmul fast float %mul, %f1 ret float %mul1 -; CHECK: @fmul6 +; CHECK-LABEL: @fmul6( ; CHECK: fmul fast float %f1, %f1 } @@ -238,7 +304,7 @@ define float @fmul7(float %f1, float %f2) { %mul1 = fmul fast float %mul, %f1 %add = fadd float %mul1, %mul ret float %add -; CHECK: @fmul7 +; CHECK-LABEL: @fmul7( ; CHECK: fmul fast float %mul, %f1 } @@ -252,7 +318,7 @@ define float @fneg1(float %f1, float %f2) { %sub1 = fsub nsz float 0.000000e+00, %f2 %mul = fmul float %sub, %sub1 ret float %mul -; CHECK: @fneg1 +; CHECK-LABEL: @fneg1( ; CHECK: fmul float %f1, %f2 } @@ -270,7 +336,7 @@ define float @fdiv1(float %x) { ; 0x3FF3333340000000 = 1.2f ; 0x4002666660000000 = 2.3f ; 0x3FD7303B60000000 = 0.36231884057971014492 -; CHECK: @fdiv1 +; CHECK-LABEL: @fdiv1( ; CHECK: fmul fast float %x, 0x3FD7303B60000000 } @@ -283,17 +349,26 @@ define float @fdiv2(float %x) { ; 0x3FF3333340000000 = 1.2f ; 0x4002666660000000 = 2.3f ; 0x3FE0B21660000000 = 0.52173918485641479492 -; CHECK: @fdiv2 +; CHECK-LABEL: @fdiv2( ; CHECK: fmul fast float %x, 0x3FE0B21660000000 } +define <2 x float> @fdiv2_vec(<2 x float> %x) { + %mul = fmul <2 x float> %x, + %div1 = fdiv fast <2 x float> %mul, + ret <2 x float> %div1 + +; CHECK-LABEL: @fdiv2_vec( +; CHECK: fmul fast <2 x float> %x, +} + ; "X/C1 / C2 => X * (1/(C2*C1))" is disabled (for now) is C2/C1 is a denormal ; define float @fdiv3(float %x) { %div = fdiv float %x, 0x47EFFFFFE0000000 %div1 = fdiv fast float %div, 0x4002666660000000 ret float %div1 -; CHECK: @fdiv3 +; CHECK-LABEL: @fdiv3( ; CHECK: fdiv float %x, 0x47EFFFFFE0000000 } @@ -302,7 +377,7 @@ define float @fdiv4(float %x) { %mul = fmul float %x, 0x47EFFFFFE0000000 %div = fdiv float %mul, 0x3FC99999A0000000 ret float %div -; CHECK: @fdiv4 +; CHECK-LABEL: @fdiv4( ; CHECK: fmul float %x, 0x47EFFFFFE0000000 } @@ -311,7 +386,7 @@ define float @fdiv5(float %f1, float %f2, float %f3) { %t1 = fdiv float %f1, %f2 %t2 = fdiv fast float %t1, %f3 ret float %t2 -; CHECK: @fdiv5 +; CHECK-LABEL: @fdiv5( ; CHECK: fmul float %f2, %f3 } @@ -320,7 +395,7 @@ define float @fdiv6(float %f1, float %f2, float %f3) { %t1 = fdiv float %f1, %f2 %t2 = fdiv fast float %f3, %t1 ret float %t2 -; CHECK: @fdiv6 +; CHECK-LABEL: @fdiv6( ; CHECK: fmul float %f3, %f2 } @@ -329,7 +404,7 @@ define float @fdiv7(float %x) { %t1 = fmul float %x, 3.0e0 %t2 = fdiv fast float 15.0e0, %t1 ret float %t2 -; CHECK: @fdiv7 +; CHECK-LABEL: @fdiv7( ; CHECK: fdiv fast float 5.000000e+00, %x } @@ -338,7 +413,7 @@ define float @fdiv8(float %x) { %t1 = fdiv float %x, 3.0e0 %t2 = fdiv fast float 15.0e0, %t1 ret float %t2 -; CHECK: @fdiv8 +; CHECK-LABEL: @fdiv8( ; CHECK: fdiv fast float 4.500000e+01, %x } @@ -347,7 +422,7 @@ define float @fdiv9(float %x) { %t1 = fdiv float 3.0e0, %x %t2 = fdiv fast float 15.0e0, %t1 ret float %t2 -; CHECK: @fdiv9 +; CHECK-LABEL: @fdiv9( ; CHECK: fmul fast float %x, 5.000000e+00 } @@ -362,7 +437,7 @@ define float @fact_mul1(float %x, float %y, float %z) { %t2 = fmul fast float %y, %z %t3 = fadd fast float %t1, %t2 ret float %t3 -; CHECK: @fact_mul1 +; CHECK-LABEL: @fact_mul1( ; CHECK: fmul fast float %1, %z } @@ -372,7 +447,7 @@ define float @fact_mul2(float %x, float %y, float %z) { %t2 = fmul fast float %y, %z %t3 = fsub fast float %t1, %t2 ret float %t3 -; CHECK: @fact_mul2 +; CHECK-LABEL: @fact_mul2( ; CHECK: fmul fast float %1, %z } @@ -382,7 +457,7 @@ define float @fact_mul3(float %x, float %y, float %z) { %t1 = fmul fast float %z, %x %t3 = fsub fast float %t1, %t2 ret float %t3 -; CHECK: @fact_mul3 +; CHECK-LABEL: @fact_mul3( ; CHECK: fmul fast float %1, %z } @@ -392,7 +467,7 @@ define float @fact_mul4(float %x, float %y, float %z) { %t2 = fmul fast float %z, %y %t3 = fsub fast float %t1, %t2 ret float %t3 -; CHECK: @fact_mul4 +; CHECK-LABEL: @fact_mul4( ; CHECK: fmul fast float %1, %z }