1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -march=sparc -mcpu=v9 | FileCheck %s
4 define i32 @f(i32 %x) {
6 ; CHECK: .cfi_startproc
7 ; CHECK-NEXT: ! %bb.0: ! %entry
8 ; CHECK-NEXT: sub %g0, %o0, %o1
9 ; CHECK-NEXT: and %o0, %o1, %o1
10 ; CHECK-NEXT: sethi 122669, %o2
11 ; CHECK-NEXT: or %o2, 305, %o2
12 ; CHECK-NEXT: smul %o1, %o2, %o1
13 ; CHECK-NEXT: srl %o1, 27, %o1
14 ; CHECK-NEXT: sethi %hi(.LCPI0_0), %o2
15 ; CHECK-NEXT: add %o2, %lo(.LCPI0_0), %o2
16 ; CHECK-NEXT: ldub [%o2+%o1], %o1
17 ; CHECK-NEXT: cmp %o0, 0
18 ; CHECK-NEXT: move %icc, 0, %o1
20 ; CHECK-NEXT: mov %o1, %o0
22 %0 = call i32 @llvm.cttz.i32(i32 %x, i1 true)
23 %1 = icmp eq i32 %x, 0
24 %2 = select i1 %1, i32 0, i32 %0
25 %3 = trunc i32 %2 to i8
26 %conv = zext i8 %3 to i32
30 define i64 @g(i64 %x) {
32 ; CHECK: .cfi_startproc
33 ; CHECK-NEXT: ! %bb.0: ! %entry
34 ; CHECK-NEXT: sub %g0, %o1, %o2
35 ; CHECK-NEXT: and %o1, %o2, %o2
36 ; CHECK-NEXT: sethi 122669, %o3
37 ; CHECK-NEXT: or %o3, 305, %o3
38 ; CHECK-NEXT: smul %o2, %o3, %o2
39 ; CHECK-NEXT: sethi %hi(.LCPI1_0), %o4
40 ; CHECK-NEXT: add %o4, %lo(.LCPI1_0), %o4
41 ; CHECK-NEXT: sub %g0, %o0, %o5
42 ; CHECK-NEXT: and %o0, %o5, %o5
43 ; CHECK-NEXT: smul %o5, %o3, %o3
44 ; CHECK-NEXT: srl %o3, 27, %o3
45 ; CHECK-NEXT: ldub [%o4+%o3], %o3
46 ; CHECK-NEXT: srl %o2, 27, %o2
47 ; CHECK-NEXT: ldub [%o4+%o2], %o4
48 ; CHECK-NEXT: add %o3, 32, %o2
49 ; CHECK-NEXT: cmp %o1, 0
50 ; CHECK-NEXT: movne %icc, %o4, %o2
51 ; CHECK-NEXT: or %o1, %o0, %o0
52 ; CHECK-NEXT: cmp %o0, 0
53 ; CHECK-NEXT: move %icc, 0, %o2
54 ; CHECK-NEXT: mov %g0, %o0
56 ; CHECK-NEXT: mov %o2, %o1
58 %0 = call i64 @llvm.cttz.i64(i64 %x, i1 true)
59 %1 = icmp eq i64 %x, 0
60 %2 = select i1 %1, i64 0, i64 %0
61 %3 = trunc i64 %2 to i32
62 %conv = zext i32 %3 to i64
66 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
67 declare i32 @llvm.cttz.i32(i32, i1 immarg) #0
68 declare i64 @llvm.cttz.i64(i64, i1 immarg) #0
70 attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }