diff options
| author | Stephen Lin <stephenwlin@gmail.com> | 2013-07-20 07:13:13 +0000 |
|---|---|---|
| committer | Stephen Lin <stephenwlin@gmail.com> | 2013-07-20 07:13:13 +0000 |
| commit | a9b57f6bea970d29f027ed01ab8c86ad7992c757 (patch) | |
| tree | 53ee7a01f4eb80f04f09b80d52670b6069bb85bf /llvm/test | |
| parent | 727aa349ad3c49d590693961ae0d0dfb39d95089 (diff) | |
| download | bcm5719-llvm-a9b57f6bea970d29f027ed01ab8c86ad7992c757.tar.gz bcm5719-llvm-a9b57f6bea970d29f027ed01ab8c86ad7992c757.zip | |
InstCombine: call FoldOpIntoSelect for all floating binops, not just fmul
llvm-svn: 186759
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fold-fops-into-selects.ll | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fold-fops-into-selects.ll b/llvm/test/Transforms/InstCombine/fold-fops-into-selects.ll new file mode 100644 index 00000000000..07aebb13eff --- /dev/null +++ b/llvm/test/Transforms/InstCombine/fold-fops-into-selects.ll @@ -0,0 +1,71 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +define float @test1(i1 %A) { +EntryBlock: + %cf = select i1 %A, float 1.000000e+00, float 0.000000e+00 + %op = fsub float 1.000000e+00, %cf + ret float %op +; CHECK-LABEL: @test1( +; CHECK: select i1 %A, float 0.000000e+00, float 1.000000e+00 +} + +define float @test2(i1 %A, float %B) { +EntryBlock: + %cf = select i1 %A, float 1.000000e+00, float %B + %op = fadd float 2.000000e+00, %cf + ret float %op +; CHECK-LABEL: @test2( +; CHECK: [[OP:%.*]] = fadd float %B, 2.000000e+00 +; CHECK: select i1 %A, float 3.000000e+00, float [[OP]] +} + +define float @test3(i1 %A, float %B) { +EntryBlock: + %cf = select i1 %A, float 1.000000e+00, float %B + %op = fsub float 2.000000e+00, %cf + ret float %op +; CHECK-LABEL: @test3( +; CHECK: [[OP:%.*]] = fsub float 2.000000e+00, %B +; CHECK: select i1 %A, float 1.000000e+00, float [[OP]] +} + +define float @test4(i1 %A, float %B) { +EntryBlock: + %cf = select i1 %A, float 1.000000e+00, float %B + %op = fmul float 2.000000e+00, %cf + ret float %op +; CHECK-LABEL: @test4( +; CHECK: [[OP:%.*]] = fmul float %B, 2.000000e+00 +; CHECK: select i1 %A, float 2.000000e+00, float [[OP]] +} + +define float @test5(i1 %A, float %B) { +EntryBlock: + %cf = select i1 %A, float 1.000000e+00, float %B + %op = fdiv float 2.000000e+00, %cf + ret float %op +; CHECK-LABEL: @test5( +; CHECK: [[OP:%.*]] = fdiv float 2.000000e+00, %B +; CHECK: select i1 %A, float 2.000000e+00, float [[OP]] +} + +define float @test6(i1 %A, float %B) { +EntryBlock: + %cf = select i1 %A, float 1.000000e+00, float %B + %op = fdiv float %cf, 2.000000e+00 + ret float %op +; CHECK-LABEL: @test6( +; CHECK: [[OP:%.*]] = fmul float %B, 5.000000e-01 +; CHECK: select i1 %A, float 5.000000e-01, float [[OP]] +} + +define float @test7(i1 %A, float %B) { +EntryBlock: + %cf = select i1 %A, float 1.000000e+00, float %B + %op = fdiv float %cf, 3.000000e+00 + ret float %op +; CHECK-LABEL: @test7( +; CHECK: [[OP:%.*]] = fdiv float %B, 3.000000e+00 +; CHECK: select i1 %A, float 0x3FD5555560000000, float [[OP]] +} + |

