diff options
| author | Quentin Colombet <qcolombet@apple.com> | 2013-02-28 21:12:40 +0000 |
|---|---|---|
| committer | Quentin Colombet <qcolombet@apple.com> | 2013-02-28 21:12:40 +0000 |
| commit | e684a6d4aa09502b2865f82511abaea71158b488 (patch) | |
| tree | 4638d0bcaa071c14ed767b7b18c017874e7b0a2f /llvm/test/Transforms/InstCombine/fast-math.ll | |
| parent | da288955975c07d8f59ecb8ec3c15c2948d2f514 (diff) | |
| download | bcm5719-llvm-e684a6d4aa09502b2865f82511abaea71158b488.tar.gz bcm5719-llvm-e684a6d4aa09502b2865f82511abaea71158b488.zip | |
Fix a bug in instcombine for fmul in fast math mode.
The instcombine recognized pattern looks like:
a = b * c
d = a +/- Cst
or
a = b * c
d = Cst +/- a
When creating the new operands for fadd or fsub instruction following the related fmul, the first operand was created with the second original operand (M0 was created with C1) and the second with the first (M1 with Opnd0).
The fix consists in creating the new operands with the appropriate original operand, i.e., M0 with Opnd0 and M1 with C1.
llvm-svn: 176300
Diffstat (limited to 'llvm/test/Transforms/InstCombine/fast-math.ll')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fast-math.ll | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fast-math.ll b/llvm/test/Transforms/InstCombine/fast-math.ll index c97bd28222b..3e32a2e4dd4 100644 --- a/llvm/test/Transforms/InstCombine/fast-math.ll +++ b/llvm/test/Transforms/InstCombine/fast-math.ll @@ -172,6 +172,17 @@ define double @fmul_distribute3(double %f1) { ; CHECK: fmul fast double %t2, 0x10000000000000 } +; ((X*C1) + C2) * C3 => (X * (C1*C3)) + (C2*C3) (i.e. distribution) +define float @fmul_distribute4(float %f1) { + %t1 = fmul float %f1, 6.0e+3 + %t2 = fsub float 2.0e+3, %t1 + %t3 = fmul fast float %t2, 5.0e+3 + ret float %t3 +; CHECK: @fmul_distribute4 +; CHECK: %1 = fmul fast float %f1, 3.000000e+07 +; CHECK: %t3 = fsub fast float 1.000000e+07, %1 +} + ; C1/X * C2 => (C1*C2) / X define float @fmul2(float %f1) { %t1 = fdiv float 2.0e+3, %f1 |

