blob: bf608b35dffd559713384ce714646f441981f083 [file] [log] [blame]
Davide Italiano85ad36b2016-12-15 23:45:11 +00001; RUN: opt < %s -instcombine -S | FileCheck %s
2
3target triple = "x86_64-unknown-freebsd11.0"
4
5
6; CHECK-LABEL: define i32 @myfls(
7; CHECK: ret i32 6
8; CHECK: }
9
10define i32 @myfls() {
11entry:
12 %call = call i32 @fls(i32 42)
13 ret i32 %call
14}
15
16; CHECK-LABEL: define i32 @myflsl(
17; CHECK: ret i32 6
18; CHECK: }
19
20define i32 @myflsl() {
21 %patatino = call i32 @flsl(i64 42)
22 ret i32 %patatino
23}
24
25; CHECK-LABEL: define i32 @myflsll(
26; CHECK: ret i32 6
27; CHECK: }
28
29define i32 @myflsll() {
30 %whatever = call i32 @flsll(i64 42)
31 ret i32 %whatever
32}
33
34; Lower to llvm.ctlz() if the argument is not a constant
35; CHECK-LABEL: define i32 @flsnotconst(
36; CHECK-NEXT: %ctlz = call i64 @llvm.ctlz.i64(i64 %z, i1 false)
37; CHECK-NEXT: %1 = sub nsw i64 64, %ctlz
38; CHECK-NEXT: %2 = trunc i64 %1 to i32
39; CHECK-NEXT: ret i32 %2
40
41define i32 @flsnotconst(i64 %z) {
42 %goo = call i32 @flsl(i64 %z)
43 ret i32 %goo
44}
45
46declare i32 @fls(i32)
47declare i32 @flsl(i64)
48declare i32 @flsll(i64)