1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 target triple = "x86_64-unknown-freebsd11.0"
8 ; CHECK-NEXT: ret i32 6
10 %call = call i32 @fls(i32 42)
14 define i32 @myflsl() {
15 ; CHECK-LABEL: @myflsl(
16 ; CHECK-NEXT: ret i32 6
18 %patatino = call i32 @flsl(i64 42)
22 define i32 @myflsll() {
23 ; CHECK-LABEL: @myflsll(
24 ; CHECK-NEXT: ret i32 6
26 %whatever = call i32 @flsll(i64 42)
30 ; Lower to llvm.ctlz() if the argument is not a constant
32 define i32 @flsnotconst(i64 %z) {
33 ; CHECK-LABEL: @flsnotconst(
34 ; CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 [[Z:%.*]], i1 false), !range [[RNG0:![0-9]+]]
35 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[CTLZ]] to i32
36 ; CHECK-NEXT: [[GOO:%.*]] = sub nsw i32 64, [[TMP1]]
37 ; CHECK-NEXT: ret i32 [[GOO]]
39 %goo = call i32 @flsl(i64 %z)
43 ; Make sure we lower fls(0) to 0 and not to `undef`.
45 define i32 @flszero() {
46 ; CHECK-LABEL: @flszero(
47 ; CHECK-NEXT: ret i32 0
49 %zero = call i32 @fls(i32 0)
54 declare i32 @flsl(i64)
55 declare i32 @flsll(i64)