diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-02-14 19:54:51 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-02-14 19:54:51 +0000 |
| commit | af5d499cb9a7bf4edbabec9432f7eb42b5197592 (patch) | |
| tree | b7e2afcc7b1833f4218030e2d42e2b749d975fad /llvm | |
| parent | 71867532187d45df623b7e4658be7bea06ee3f3e (diff) | |
| download | bcm5719-llvm-af5d499cb9a7bf4edbabec9432f7eb42b5197592.tar.gz bcm5719-llvm-af5d499cb9a7bf4edbabec9432f7eb42b5197592.zip | |
[InstCombine] add tests and comments for fdiv X, C; NFC
llvm-svn: 325161
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fdiv.ll | 87 |
1 files changed, 77 insertions, 10 deletions
diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll index b94cfcbb459..ac9733b11c4 100644 --- a/llvm/test/Transforms/InstCombine/fdiv.ll +++ b/llvm/test/Transforms/InstCombine/fdiv.ll @@ -1,8 +1,19 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -instcombine < %s | FileCheck %s -define float @test1(float %x) { -; CHECK-LABEL: @test1( +define float @exact_inverse(float %x) { +; CHECK-LABEL: @exact_inverse( +; CHECK-NEXT: [[DIV:%.*]] = fmul float [[X:%.*]], 1.250000e-01 +; CHECK-NEXT: ret float [[DIV]] +; + %div = fdiv float %x, 8.0 + ret float %div +} + +; Min normal float = 1.17549435E-38 + +define float @exact_inverse2(float %x) { +; CHECK-LABEL: @exact_inverse2( ; CHECK-NEXT: [[DIV:%.*]] = fmul float [[X:%.*]], 0x47D0000000000000 ; CHECK-NEXT: ret float [[DIV]] ; @@ -10,8 +21,10 @@ define float @test1(float %x) { ret float %div } -define float @test2(float %x) { -; CHECK-LABEL: @test2( +; Max exponent = 1.70141183E+38; don't transform to multiply with denormal. + +define float @exact_inverse_but_denorm(float %x) { +; CHECK-LABEL: @exact_inverse_but_denorm( ; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[X:%.*]], 0x47E0000000000000 ; CHECK-NEXT: ret float [[DIV]] ; @@ -19,8 +32,10 @@ define float @test2(float %x) { ret float %div } -define float @test3(float %x) { -; CHECK-LABEL: @test3( +; Denormal = float 1.40129846E-45; inverse can't be represented. + +define float @not_exact_inverse2(float %x) { +; CHECK-LABEL: @not_exact_inverse2( ; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[X:%.*]], 0x36A0000000000000 ; CHECK-NEXT: ret float [[DIV]] ; @@ -28,15 +43,67 @@ define float @test3(float %x) { ret float %div } -define float @test4(float %x) { -; CHECK-LABEL: @test4( -; CHECK-NEXT: [[DIV:%.*]] = fmul fast float [[X:%.*]], 1.250000e-01 +; Fast math allows us to replace this fdiv. + +define float @not_exact_but_allow_recip(float %x) { +; CHECK-LABEL: @not_exact_but_allow_recip( +; CHECK-NEXT: [[DIV:%.*]] = fmul arcp float [[X:%.*]], 0x3FD5555560000000 +; CHECK-NEXT: ret float [[DIV]] +; + %div = fdiv arcp float %x, 3.0 + ret float %div +} + +; Fast math allows us to replace this fdiv, but we don't to avoid a denormal. +; TODO: What if the function attributes tell us that denormals are flushed? + +define float @not_exact_but_allow_recip_but_denorm(float %x) { +; CHECK-LABEL: @not_exact_but_allow_recip_but_denorm( +; CHECK-NEXT: [[DIV:%.*]] = fdiv arcp float [[X:%.*]], 0x47E0000100000000 ; CHECK-NEXT: ret float [[DIV]] ; - %div = fdiv fast float %x, 8.0 + %div = fdiv arcp float %x, 0x47E0000100000000 ret float %div } +; FIXME: Vector neglect. + +define <2 x float> @exact_inverse_splat(<2 x float> %x) { +; CHECK-LABEL: @exact_inverse_splat( +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], <float 4.000000e+00, float 4.000000e+00> +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %div = fdiv <2 x float> %x, <float 4.0, float 4.0> + ret <2 x float> %div +} + +define <2 x float> @exact_inverse_vec(<2 x float> %x) { +; CHECK-LABEL: @exact_inverse_vec( +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], <float 4.000000e+00, float 8.000000e+00> +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %div = fdiv <2 x float> %x, <float 4.0, float 8.0> + ret <2 x float> %div +} + +define <2 x float> @not_exact_inverse_splat(<2 x float> %x) { +; CHECK-LABEL: @not_exact_inverse_splat( +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], <float 3.000000e+00, float 3.000000e+00> +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %div = fdiv <2 x float> %x, <float 3.0, float 3.0> + ret <2 x float> %div +} + +define <2 x float> @not_exact_inverse_vec(<2 x float> %x) { +; CHECK-LABEL: @not_exact_inverse_vec( +; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], <float 4.000000e+00, float 3.000000e+00> +; CHECK-NEXT: ret <2 x float> [[DIV]] +; + %div = fdiv <2 x float> %x, <float 4.0, float 3.0> + ret <2 x float> %div +} + define float @test5(float %x, float %y, float %z) { ; CHECK-LABEL: @test5( ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[Y:%.*]], [[Z:%.*]] |

