diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2014-08-14 15:23:01 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2014-08-14 15:23:01 +0000 |
commit | 11ab9416445cfe62602a4bd0d8503d95c96e5857 (patch) | |
tree | 49924ac0503bd262c55d4abec1670653c648bfda /llvm/test/Transforms/Reassociate/fast-multistep.ll | |
parent | 35d3133650e7f1907d03c98886286e328cee12e8 (diff) | |
download | bcm5719-llvm-11ab9416445cfe62602a4bd0d8503d95c96e5857.tar.gz bcm5719-llvm-11ab9416445cfe62602a4bd0d8503d95c96e5857.zip |
[Reassociation] Add support for reassociation with unsafe algebra.
Vector instructions are (still) not supported for either integer or floating
point. Hopefully, that work will be landed shortly.
llvm-svn: 215647
Diffstat (limited to 'llvm/test/Transforms/Reassociate/fast-multistep.ll')
-rw-r--r-- | llvm/test/Transforms/Reassociate/fast-multistep.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Reassociate/fast-multistep.ll b/llvm/test/Transforms/Reassociate/fast-multistep.ll new file mode 100644 index 00000000000..45e15c7f353 --- /dev/null +++ b/llvm/test/Transforms/Reassociate/fast-multistep.ll @@ -0,0 +1,32 @@ +; RUN: opt < %s -reassociate -S | FileCheck %s + +define float @fmultistep1(float %a, float %b, float %c) { +; Check that a*a*b+a*a*c is turned into a*(a*(b+c)). +; CHECK-LABEL: @fmultistep1 +; CHECK-NEXT: fadd fast float %c, %b +; CHECK-NEXT: fmul fast float %a, %tmp2 +; CHECK-NEXT: fmul fast float %tmp3, %a +; CHECK-NEXT: ret float + + %t0 = fmul fast float %a, %b + %t1 = fmul fast float %a, %t0 ; a*(a*b) + %t2 = fmul fast float %a, %c + %t3 = fmul fast float %a, %t2 ; a*(a*c) + %t4 = fadd fast float %t1, %t3 + ret float %t4 +} + +define float @fmultistep2(float %a, float %b, float %c, float %d) { +; Check that a*b+a*c+d is turned into a*(b+c)+d. +; CHECK-LABEL: @fmultistep2 +; CHECK-NEXT: fadd fast float %c, %b +; CHECK-NEXT: fmul fast float %tmp, %a +; CHECK-NEXT: fadd fast float %tmp1, %d +; CHECK-NEXT: ret float + + %t0 = fmul fast float %a, %b + %t1 = fmul fast float %a, %c + %t2 = fadd fast float %t1, %d ; a*c+d + %t3 = fadd fast float %t0, %t2 ; a*b+(a*c+d) + ret float %t3 +} |