1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 target triple = "x86_64-unknown-freebsd11.0"
7 ; CHECK-NEXT: ret i32 6
9 %call = call i32 @fls(i32 42)
13 define i32 @myflsl() {
14 ; CHECK-LABEL: @myflsl(
15 ; CHECK-NEXT: ret i32 6
17 %patatino = call i32 @flsl(i64 42)
21 define i32 @myflsll() {
22 ; CHECK-LABEL: @myflsll(
23 ; CHECK-NEXT: ret i32 6
25 %whatever = call i32 @flsll(i64 42)
29 ; Lower to llvm.ctlz() if the argument is not a constant
31 define i32 @flsnotconst(i64 %z) {
32 ; CHECK-LABEL: @flsnotconst(
33 ; CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 %z, i1 false), !range !0
34 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[CTLZ]] to i32
35 ; CHECK-NEXT: [[TMP2:%.*]] = sub nsw i32 64, [[TMP1]]
36 ; CHECK-NEXT: ret i32 [[TMP2]]
38 %goo = call i32 @flsl(i64 %z)
42 ; Make sure we lower fls(0) to 0 and not to `undef`.
44 define i32 @flszero() {
45 ; CHECK-LABEL: @flszero(
46 ; CHECK-NEXT: ret i32 0
48 %zero = call i32 @fls(i32 0)
53 declare i32 @flsl(i64)
54 declare i32 @flsll(i64)