1 ; RUN: llc < %s -mtriple=arm64-apple-ios7.0.0 | FileCheck %s
2 ; RUN: llc < %s -mtriple=arm64-apple-ios7.0.0 -O0 -pass-remarks-missed=gisel* -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL,FALLBACK
4 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
6 ; Function Attrs: nounwind readnone
7 declare i32 @llvm.ctlz.i32(i32, i1) #0
8 declare i64 @llvm.ctlz.i64(i64, i1) #1
10 ; Function Attrs: nounwind ssp
11 ; FALLBACK-NOT: remark{{.*}}clrsb32
12 define i32 @clrsb32(i32 %x) #2 {
14 %shr = ashr i32 %x, 31
15 %xor = xor i32 %shr, %x
16 %mul = shl i32 %xor, 1
18 %0 = tail call i32 @llvm.ctlz.i32(i32 %add, i1 false)
21 ; CHECK-LABEL: clrsb32
22 ; CHECK: cls [[TEMP:w[0-9]+]], [[TEMP]]
24 ; GISEL-LABEL: clrsb32
25 ; GISEL: cls [[TEMP:w[0-9]+]], [[TEMP]]
28 ; Function Attrs: nounwind ssp
29 ; FALLBACK-NOT: remark{{.*}}clrsb64
30 define i64 @clrsb64(i64 %x) #3 {
32 %shr = ashr i64 %x, 63
33 %xor = xor i64 %shr, %x
34 %mul = shl nsw i64 %xor, 1
36 %0 = tail call i64 @llvm.ctlz.i64(i64 %add, i1 false)
39 ; CHECK-LABEL: clrsb64
40 ; CHECK: cls [[TEMP:x[0-9]+]], [[TEMP]]
41 ; GISEL-LABEL: clrsb64
42 ; GISEL: cls [[TEMP:x[0-9]+]], [[TEMP]]
45 ; Function Attrs: nounwind ssp
46 ; FALLBACK-NOT: remark{{.*}}clrsb32_zeroundef
47 define i32 @clrsb32_zeroundef(i32 %x) #2 {
49 %shr = ashr i32 %x, 31
50 %xor = xor i32 %shr, %x
51 %mul = shl i32 %xor, 1
53 %0 = tail call i32 @llvm.ctlz.i32(i32 %add, i1 true)
56 ; CHECK-LABEL: clrsb32_zeroundef
57 ; CHECK: cls [[TEMP:w[0-9]+]], [[TEMP]]
59 ; GISEL-LABEL: clrsb32_zeroundef
60 ; GISEL: cls [[TEMP:w[0-9]+]], [[TEMP]]
63 ; Function Attrs: nounwind ssp
64 ; FALLBACK-NOT: remark{{.*}}clrsb64
65 define i64 @clrsb64_zeroundef(i64 %x) #3 {
67 %shr = ashr i64 %x, 63
68 %xor = xor i64 %shr, %x
69 %mul = shl nsw i64 %xor, 1
71 %0 = tail call i64 @llvm.ctlz.i64(i64 %add, i1 true)
74 ; CHECK-LABEL: clrsb64_zeroundef
75 ; CHECK: cls [[TEMP:x[0-9]+]], [[TEMP]]
76 ; GISEL-LABEL: clrsb64_zeroundef
77 ; GISEL: cls [[TEMP:x[0-9]+]], [[TEMP]]