diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-08-07 22:30:43 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-08-07 22:30:43 +0000 |
| commit | 25887da162dd416bffaa5c25253a21b75ee6d9fc (patch) | |
| tree | 5aa789c02698a8525232a0ec29302d52ed7608f8 /llvm/test | |
| parent | 381e9d2386facea7f2acc0f8c16a6d0731267f80 (diff) | |
| download | bcm5719-llvm-25887da162dd416bffaa5c25253a21b75ee6d9fc.tar.gz bcm5719-llvm-25887da162dd416bffaa5c25253a21b75ee6d9fc.zip | |
[InstCombine] add tests for fneg of fmul/fdiv with constant; NFC
llvm-svn: 339195
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fneg.ll | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fneg.ll b/llvm/test/Transforms/InstCombine/fneg.ll new file mode 100644 index 00000000000..bd8ed121127 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/fneg.ll @@ -0,0 +1,128 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -instcombine -S | FileCheck %s + +declare void @use(float) + +; -(X * C) --> X * (-C) + +define float @fmul_fneg(float %x) { +; CHECK-LABEL: @fmul_fneg( +; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[M]] +; CHECK-NEXT: ret float [[R]] +; + %m = fmul float %x, 42.0 + %r = fsub float -0.0, %m + ret float %r +} + +; Extra use is ok. + +define float @fmul_fneg_extra_use(float %x) { +; CHECK-LABEL: @fmul_fneg_extra_use( +; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[M]] +; CHECK-NEXT: call void @use(float [[M]]) +; CHECK-NEXT: ret float [[R]] +; + %m = fmul float %x, 42.0 + %r = fsub float -0.0, %m + call void @use(float %m) + ret float %r +} + +; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything. + +define <4 x double> @fmul_fneg_vec(<4 x double> %x) { +; CHECK-LABEL: @fmul_fneg_vec( +; CHECK-NEXT: [[M:%.*]] = fmul <4 x double> [[X:%.*]], <double 4.200000e+01, double 0xFF80000000000000, double 0x7FF0000000000000, double undef> +; CHECK-NEXT: [[R:%.*]] = fsub <4 x double> <double -0.000000e+00, double -0.000000e+00, double -0.000000e+00, double -0.000000e+00>, [[M]] +; CHECK-NEXT: ret <4 x double> [[R]] +; + %m = fmul <4 x double> %x, <double 42.0, double 0x7FF80000000000000, double 0x7FF0000000000000, double undef> + %r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %m + ret <4 x double> %r +} + +; -(X / C) --> X / (-C) + +define float @fdiv_op1_constant_fneg(float %x) { +; CHECK-LABEL: @fdiv_op1_constant_fneg( +; CHECK-NEXT: [[D:%.*]] = fdiv float [[X:%.*]], -4.200000e+01 +; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[D]] +; CHECK-NEXT: ret float [[R]] +; + %d = fdiv float %x, -42.0 + %r = fsub float -0.0, %d + ret float %r +} + +; Extra use is ok. + +define float @fdiv_op1_constant_fneg_extra_use(float %x) { +; CHECK-LABEL: @fdiv_op1_constant_fneg_extra_use( +; CHECK-NEXT: [[D:%.*]] = fdiv float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[D]] +; CHECK-NEXT: call void @use(float [[D]]) +; CHECK-NEXT: ret float [[R]] +; + %d = fdiv float %x, 42.0 + %r = fsub float -0.0, %d + call void @use(float %d) + ret float %r +} + +; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything. + +define <4 x double> @fdiv_op1_constant_fneg_vec(<4 x double> %x) { +; CHECK-LABEL: @fdiv_op1_constant_fneg_vec( +; CHECK-NEXT: [[D:%.*]] = fdiv <4 x double> [[X:%.*]], <double -4.200000e+01, double 0.000000e+00, double 0xFFF0000000000000, double undef> +; CHECK-NEXT: [[R:%.*]] = fsub <4 x double> <double -0.000000e+00, double -0.000000e+00, double -0.000000e+00, double -0.000000e+00>, [[D]] +; CHECK-NEXT: ret <4 x double> [[R]] +; + %d = fdiv <4 x double> %x, <double -42.0, double 0xFFF800000ABCD0000, double 0xFFF0000000000000, double undef> + %r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %d + ret <4 x double> %r +} + +; -(C / X) --> (-C) / X + +define float @fdiv_op0_constant_fneg(float %x) { +; CHECK-LABEL: @fdiv_op0_constant_fneg( +; CHECK-NEXT: [[D:%.*]] = fdiv float 4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[D]] +; CHECK-NEXT: ret float [[R]] +; + %d = fdiv float 42.0, %x + %r = fsub float -0.0, %d + ret float %r +} + +; Extra use is ok. + +define float @fdiv_op0_constant_fneg_extra_use(float %x) { +; CHECK-LABEL: @fdiv_op0_constant_fneg_extra_use( +; CHECK-NEXT: [[D:%.*]] = fdiv float -4.200000e+01, [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[D]] +; CHECK-NEXT: call void @use(float [[D]]) +; CHECK-NEXT: ret float [[R]] +; + %d = fdiv float -42.0, %x + %r = fsub float -0.0, %d + call void @use(float %d) + ret float %r +} + +; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything. + +define <4 x double> @fdiv_op0_constant_fneg_vec(<4 x double> %x) { +; CHECK-LABEL: @fdiv_op0_constant_fneg_vec( +; CHECK-NEXT: [[D:%.*]] = fdiv <4 x double> <double -4.200000e+01, double 0xFF80000000000000, double 0xFFF0000000000000, double undef>, [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fsub <4 x double> <double -0.000000e+00, double -0.000000e+00, double -0.000000e+00, double -0.000000e+00>, [[D]] +; CHECK-NEXT: ret <4 x double> [[R]] +; + %d = fdiv <4 x double> <double -42.0, double 0x7FF80000000000000, double 0xFFF0000000000000, double undef>, %x + %r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %d + ret <4 x double> %r +} + |

