blob: 02368cb4a4c42ac5af4bd84744b9bee3dc961144 [file] [log] [blame]
Simon Pilgrimfc4d4b22016-07-19 13:35:11 +00001; RUN: llc < %s -mtriple=arm64-apple-ios7.0.0 | FileCheck %s
Louis Gerbargb9a05512014-04-11 22:27:58 +00002
3target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
Louis Gerbargb9a05512014-04-11 22:27:58 +00004
5; Function Attrs: nounwind readnone
6declare i32 @llvm.ctlz.i32(i32, i1) #0
7declare i64 @llvm.ctlz.i64(i64, i1) #1
8
9; Function Attrs: nounwind ssp
10define i32 @clrsb32(i32 %x) #2 {
11entry:
12 %shr = ashr i32 %x, 31
13 %xor = xor i32 %shr, %x
14 %mul = shl i32 %xor, 1
15 %add = or i32 %mul, 1
16 %0 = tail call i32 @llvm.ctlz.i32(i32 %add, i1 false)
17
18 ret i32 %0
19; CHECK-LABEL: clrsb32
20; CHECK: cls [[TEMP:w[0-9]+]], [[TEMP]]
21}
22
23; Function Attrs: nounwind ssp
24define i64 @clrsb64(i64 %x) #3 {
25entry:
26 %shr = ashr i64 %x, 63
27 %xor = xor i64 %shr, %x
28 %mul = shl nsw i64 %xor, 1
29 %add = or i64 %mul, 1
30 %0 = tail call i64 @llvm.ctlz.i64(i64 %add, i1 false)
31
32 ret i64 %0
33; CHECK-LABEL: clrsb64
34; CHECK: cls [[TEMP:x[0-9]+]], [[TEMP]]
35}