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 ; FIXME: We should produce the same result here to save some code size. After
25 ; that, we can remove the GISEL special casing.
26 ; GISEL-LABEL: clrsb32
30 ; Function Attrs: nounwind ssp
31 ; FALLBACK-NOT: remark{{.*}}clrsb64
32 define i64 @clrsb64(i64 %x) #3 {
34 %shr = ashr i64 %x, 63
35 %xor = xor i64 %shr, %x
36 %mul = shl nsw i64 %xor, 1
38 %0 = tail call i64 @llvm.ctlz.i64(i64 %add, i1 false)
41 ; CHECK-LABEL: clrsb64
42 ; CHECK: cls [[TEMP:x[0-9]+]], [[TEMP]]
43 ; GISEL-LABEL: clrsb64
44 ; GISEL: cls [[TEMP:x[0-9]+]], [[TEMP]]