diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-04-03 22:19:19 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-04-03 22:19:19 +0000 |
| commit | 81b3b10a9509f970ea8ef76eebfb7e349a3dff92 (patch) | |
| tree | 44c675749f786f2e80094bcf2262c0d3d77afa0d /llvm/test | |
| parent | 642f6c61a3dcc1d9f66e31e2e1f3f72838dc1233 (diff) | |
| download | bcm5719-llvm-81b3b10a9509f970ea8ef76eebfb7e349a3dff92.tar.gz bcm5719-llvm-81b3b10a9509f970ea8ef76eebfb7e349a3dff92.zip | |
[InstCombine] allow more fmul folds with 'reassoc'
The tests marked with 'FIXME' require loosening the check
in SimplifyAssociativeOrCommutative() to optimize completely;
that's still checking isFast() in Instruction::isAssociative().
llvm-svn: 329121
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fmul.ll | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/llvm/test/Transforms/InstCombine/fmul.ll b/llvm/test/Transforms/InstCombine/fmul.ll index bd5de2c8ad1..4d8557f2645 100644 --- a/llvm/test/Transforms/InstCombine/fmul.ll +++ b/llvm/test/Transforms/InstCombine/fmul.ll @@ -336,11 +336,11 @@ define float @log2half_commute(float %x1, float %y) { define float @fdiv_constant_numerator_fmul(float %x) { ; CHECK-LABEL: @fdiv_constant_numerator_fmul( -; CHECK-NEXT: [[T3:%.*]] = fdiv fast float 1.200000e+07, [[X:%.*]] +; CHECK-NEXT: [[T3:%.*]] = fdiv reassoc float 1.200000e+07, [[X:%.*]] ; CHECK-NEXT: ret float [[T3]] ; %t1 = fdiv float 2.0e+3, %x - %t3 = fmul fast float %t1, 6.0e+3 + %t3 = fmul reassoc float %t1, 6.0e+3 ret float %t3 } @@ -365,21 +365,21 @@ define float @fdiv_constant_numerator_fmul_extra_use(float %x) { define float @fdiv_constant_denominator_fmul(float %x) { ; CHECK-LABEL: @fdiv_constant_denominator_fmul( -; CHECK-NEXT: [[T3:%.*]] = fmul fast float [[X:%.*]], 3.000000e+00 +; CHECK-NEXT: [[T3:%.*]] = fmul reassoc float [[X:%.*]], 3.000000e+00 ; CHECK-NEXT: ret float [[T3]] ; %t1 = fdiv float %x, 2.0e+3 - %t3 = fmul fast float %t1, 6.0e+3 + %t3 = fmul reassoc float %t1, 6.0e+3 ret float %t3 } define <4 x float> @fdiv_constant_denominator_fmul_vec(<4 x float> %x) { ; CHECK-LABEL: @fdiv_constant_denominator_fmul_vec( -; CHECK-NEXT: [[T3:%.*]] = fmul fast <4 x float> [[X:%.*]], <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00, float 1.000000e+00> +; CHECK-NEXT: [[T3:%.*]] = fmul reassoc <4 x float> [[X:%.*]], <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00, float 1.000000e+00> ; CHECK-NEXT: ret <4 x float> [[T3]] ; %t1 = fdiv <4 x float> %x, <float 2.0e+3, float 3.0e+3, float 2.0e+3, float 1.0e+3> - %t3 = fmul fast <4 x float> %t1, <float 6.0e+3, float 6.0e+3, float 2.0e+3, float 1.0e+3> + %t3 = fmul reassoc <4 x float> %t1, <float 6.0e+3, float 6.0e+3, float 2.0e+3, float 1.0e+3> ret <4 x float> %t3 } @@ -387,12 +387,12 @@ define <4 x float> @fdiv_constant_denominator_fmul_vec(<4 x float> %x) { define <4 x float> @fdiv_constant_denominator_fmul_vec_constexpr(<4 x float> %x) { ; CHECK-LABEL: @fdiv_constant_denominator_fmul_vec_constexpr( -; CHECK-NEXT: [[T3:%.*]] = fmul fast <4 x float> [[X:%.*]], <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00, float 1.000000e+00> +; CHECK-NEXT: [[T3:%.*]] = fmul reassoc <4 x float> [[X:%.*]], <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00, float 1.000000e+00> ; CHECK-NEXT: ret <4 x float> [[T3]] ; %constExprMul = bitcast i128 trunc (i160 bitcast (<5 x float> <float 6.0e+3, float 6.0e+3, float 2.0e+3, float 1.0e+3, float undef> to i160) to i128) to <4 x float> %t1 = fdiv <4 x float> %x, <float 2.0e+3, float 3.0e+3, float 2.0e+3, float 1.0e+3> - %t3 = fmul fast <4 x float> %t1, %constExprMul + %t3 = fmul reassoc <4 x float> %t1, %constExprMul ret <4 x float> %t3 } @@ -416,11 +416,11 @@ define float @fdiv_constant_denominator_fmul_denorm(float %x) { define float @fdiv_constant_denominator_fmul_denorm_try_harder(float %x) { ; CHECK-LABEL: @fdiv_constant_denominator_fmul_denorm_try_harder( -; CHECK-NEXT: [[T3:%.*]] = fdiv fast float [[X:%.*]], 0x47E8000000000000 +; CHECK-NEXT: [[T3:%.*]] = fdiv reassoc float [[X:%.*]], 0x47E8000000000000 ; CHECK-NEXT: ret float [[T3]] ; %t1 = fdiv float %x, 3.0 - %t3 = fmul fast float %t1, 0x3810000000000000 + %t3 = fmul reassoc float %t1, 0x3810000000000000 ret float %t3 } @@ -443,12 +443,12 @@ define float @fdiv_constant_denominator_fmul_denorm_try_harder_extra_use(float % define float @fmul_fadd_distribute(float %x) { ; CHECK-LABEL: @fmul_fadd_distribute( -; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], 3.000000e+00 -; CHECK-NEXT: [[T3:%.*]] = fadd fast float [[TMP1]], 6.000000e+00 +; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc float [[X:%.*]], 3.000000e+00 +; CHECK-NEXT: [[T3:%.*]] = fadd reassoc float [[TMP1]], 6.000000e+00 ; CHECK-NEXT: ret float [[T3]] ; %t2 = fadd float %x, 2.0 - %t3 = fmul fast float %t2, 3.0 + %t3 = fmul reassoc float %t2, 3.0 ret float %t3 } @@ -456,12 +456,12 @@ define float @fmul_fadd_distribute(float %x) { define float @fmul_fsub_distribute1(float %x) { ; CHECK-LABEL: @fmul_fsub_distribute1( -; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], 3.000000e+00 -; CHECK-NEXT: [[T3:%.*]] = fadd fast float [[TMP1]], -6.000000e+00 +; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc float [[X:%.*]], 3.000000e+00 +; CHECK-NEXT: [[T3:%.*]] = fadd reassoc float [[TMP1]], -6.000000e+00 ; CHECK-NEXT: ret float [[T3]] ; %t2 = fsub float %x, 2.0 - %t3 = fmul fast float %t2, 3.0 + %t3 = fmul reassoc float %t2, 3.0 ret float %t3 } @@ -469,15 +469,16 @@ define float @fmul_fsub_distribute1(float %x) { define float @fmul_fsub_distribute2(float %x) { ; CHECK-LABEL: @fmul_fsub_distribute2( -; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], 3.000000e+00 -; CHECK-NEXT: [[T3:%.*]] = fsub fast float 6.000000e+00, [[TMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc float [[X:%.*]], 3.000000e+00 +; CHECK-NEXT: [[T3:%.*]] = fsub reassoc float 6.000000e+00, [[TMP1]] ; CHECK-NEXT: ret float [[T3]] ; %t2 = fsub float 2.0, %x - %t3 = fmul fast float %t2, 3.0 + %t3 = fmul reassoc float %t2, 3.0 ret float %t3 } +; FIXME: This should only need 'reassoc'. ; ((X*C1) + C2) * C3 => (X * (C1*C3)) + (C2*C3) define float @fmul_fadd_fmul_distribute(float %x) { @@ -514,13 +515,13 @@ define float @fmul_fadd_distribute_extra_use(float %x) { define double @fmul_fadd_fdiv_distribute2(double %x) { ; CHECK-LABEL: @fmul_fadd_fdiv_distribute2( -; CHECK-NEXT: [[TMP1:%.*]] = fdiv fast double [[X:%.*]], 0x7FE8000000000000 -; CHECK-NEXT: [[T3:%.*]] = fadd fast double [[TMP1]], 0x34000000000000 +; CHECK-NEXT: [[TMP1:%.*]] = fdiv reassoc double [[X:%.*]], 0x7FE8000000000000 +; CHECK-NEXT: [[T3:%.*]] = fadd reassoc double [[TMP1]], 0x34000000000000 ; CHECK-NEXT: ret double [[T3]] ; %t1 = fdiv double %x, 3.0 %t2 = fadd double %t1, 5.0 - %t3 = fmul fast double %t2, 0x10000000000000 + %t3 = fmul reassoc double %t2, 0x10000000000000 ret double %t3 } @@ -529,16 +530,17 @@ define double @fmul_fadd_fdiv_distribute2(double %x) { define double @fmul_fadd_fdiv_distribute3(double %x) { ; CHECK-LABEL: @fmul_fadd_fdiv_distribute3( -; CHECK-NEXT: [[TMP1:%.*]] = fdiv fast double [[X:%.*]], 0x7FE8000000000000 -; CHECK-NEXT: [[T3:%.*]] = fadd fast double [[TMP1]], 0x34000000000000 +; CHECK-NEXT: [[TMP1:%.*]] = fdiv reassoc double [[X:%.*]], 0x7FE8000000000000 +; CHECK-NEXT: [[T3:%.*]] = fadd reassoc double [[TMP1]], 0x34000000000000 ; CHECK-NEXT: ret double [[T3]] ; %t1 = fdiv double %x, 3.0 %t2 = fadd double %t1, 5.0 - %t3 = fmul fast double %t2, 0x10000000000000 + %t3 = fmul reassoc double %t2, 0x10000000000000 ret double %t3 } +; FIXME: This should only need 'reassoc'. ; (C2 - (X*C1)) * C3 => (C2*C3) - (X * (C1*C3)) define float @fmul_fsub_fmul_distribute(float %x) { @@ -568,6 +570,7 @@ define float @fmul_fsub_fmul_distribute_extra_use(float %x) { ret float %t3 } +; FIXME: This should only need 'reassoc'. ; ((X*C1) - C2) * C3 => (X * (C1*C3)) - C2*C3 define float @fmul_fsub_fmul_distribute2(float %x) { |

