X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FTransforms%2FInstCombine%2Ffast-math.ll;h=2ee4b0f2c381217f5ae1e72e9a2fa6d7512f044e;hb=578c74e35da692fe0435491e1acb245f37bf6930;hp=a9a7015f62d0bbab93833fcef67f2e59a10c560a;hpb=39f4e8d9cce22b60a3417a5f17c847fa5b1daebf;p=oota-llvm.git diff --git a/test/Transforms/InstCombine/fast-math.ll b/test/Transforms/InstCombine/fast-math.ll index a9a7015f62d..2ee4b0f2c38 100644 --- a/test/Transforms/InstCombine/fast-math.ll +++ b/test/Transforms/InstCombine/fast-math.ll @@ -140,6 +140,42 @@ define float @fold13(float %x) { ; 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 @@ -202,6 +238,18 @@ define float @fmul2(float %f1) { ; 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 @@ -211,6 +259,14 @@ define float @fmul3(float %f1, float %f2) { ; 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 ; @@ -297,6 +353,15 @@ define float @fdiv2(float %x) { ; 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) {