diff options
| author | Davide Italiano <davide@freebsd.org> | 2016-12-15 23:45:11 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2016-12-15 23:45:11 +0000 |
| commit | 85ad36b0e01210fad939126e47a994b76a1cbd10 (patch) | |
| tree | 202d085344ce100cd5b5afff33568d432a85a6d3 /llvm/test | |
| parent | 2e1626879e05bf4aa57e0707dc1b6b5261e64c85 (diff) | |
| download | bcm5719-llvm-85ad36b0e01210fad939126e47a994b76a1cbd10.tar.gz bcm5719-llvm-85ad36b0e01210fad939126e47a994b76a1cbd10.zip | |
[SimplifyLibCalls] Lower fls() to llvm.ctlz().
Differential Revision: https://reviews.llvm.org/D14590
llvm-svn: 289894
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fls.ll | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fls.ll b/llvm/test/Transforms/InstCombine/fls.ll new file mode 100644 index 00000000000..bf608b35dff --- /dev/null +++ b/llvm/test/Transforms/InstCombine/fls.ll @@ -0,0 +1,48 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +target triple = "x86_64-unknown-freebsd11.0" + + +; CHECK-LABEL: define i32 @myfls( +; CHECK: ret i32 6 +; CHECK: } + +define i32 @myfls() { +entry: + %call = call i32 @fls(i32 42) + ret i32 %call +} + +; CHECK-LABEL: define i32 @myflsl( +; CHECK: ret i32 6 +; CHECK: } + +define i32 @myflsl() { + %patatino = call i32 @flsl(i64 42) + ret i32 %patatino +} + +; CHECK-LABEL: define i32 @myflsll( +; CHECK: ret i32 6 +; CHECK: } + +define i32 @myflsll() { + %whatever = call i32 @flsll(i64 42) + ret i32 %whatever +} + +; Lower to llvm.ctlz() if the argument is not a constant +; CHECK-LABEL: define i32 @flsnotconst( +; CHECK-NEXT: %ctlz = call i64 @llvm.ctlz.i64(i64 %z, i1 false) +; CHECK-NEXT: %1 = sub nsw i64 64, %ctlz +; CHECK-NEXT: %2 = trunc i64 %1 to i32 +; CHECK-NEXT: ret i32 %2 + +define i32 @flsnotconst(i64 %z) { + %goo = call i32 @flsl(i64 %z) + ret i32 %goo +} + +declare i32 @fls(i32) +declare i32 @flsl(i64) +declare i32 @flsll(i64) |

