diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-02-12 19:23:39 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-02-12 19:23:39 +0000 |
| commit | ee4257f676b81681c38cbb1ef7f3fed0ad6af4ce (patch) | |
| tree | 0989f12f64ba811b7fd0ee810e85b76e1e229774 /llvm | |
| parent | fbfdd53ad1291156e8114a6c81667bbd4c395d31 (diff) | |
| download | bcm5719-llvm-ee4257f676b81681c38cbb1ef7f3fed0ad6af4ce.tar.gz bcm5719-llvm-ee4257f676b81681c38cbb1ef7f3fed0ad6af4ce.zip | |
[InstCombine] add tests for missing fdiv fold; NFC
llvm-svn: 324926
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fdiv.ll | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll index b723ace318f..273a49c4d24 100644 --- a/llvm/test/Transforms/InstCombine/fdiv.ll +++ b/llvm/test/Transforms/InstCombine/fdiv.ll @@ -83,3 +83,45 @@ define float @fdiv_fneg_fneg_fast(float %x, float %y) { ret float %div } +; FIXME: +; X / (X * Y) --> 1.0 / Y + +define float @div_factor(float %x, float %y) { +; CHECK-LABEL: @div_factor( +; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[D:%.*]] = fdiv reassoc nnan float [[X]], [[M]] +; CHECK-NEXT: ret float [[D]] +; + %m = fmul float %x, %y + %d = fdiv nnan reassoc float %x, %m + ret float %d; +} + +; We can't do the transform without 'nnan' because if x is NAN and y is a number, this should return NAN. + +define float @div_factor_too_strict(float %x, float %y) { +; CHECK-LABEL: @div_factor_too_strict( +; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[D:%.*]] = fdiv reassoc float [[X]], [[M]] +; CHECK-NEXT: ret float [[D]] +; + %m = fmul float %x, %y + %d = fdiv reassoc float %x, %m + ret float %d +} + +; FIXME: +; Commute, verify vector types, and show that we are not dropping extra FMF. +; X / (Y * X) --> 1.0 / Y + +define <2 x float> @div_factor_commute(<2 x float> %x, <2 x float> %y) { +; CHECK-LABEL: @div_factor_commute( +; CHECK-NEXT: [[M:%.*]] = fmul <2 x float> [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: [[D:%.*]] = fdiv reassoc nnan ninf nsz <2 x float> [[X]], [[M]] +; CHECK-NEXT: ret <2 x float> [[D]] +; + %m = fmul <2 x float> %y, %x + %d = fdiv nnan ninf nsz reassoc <2 x float> %x, %m + ret <2 x float> %d +} + |

