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