From 9d2051f7fa1b10c4c768e02948365fbc5d80422a Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 24 Dec 2011 11:26:59 +0000 Subject: [PATCH] Add i8 and i64 testing for ctlz on x86. Also simplify the i16 test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147249 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/X86/clz.ll | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/test/CodeGen/X86/clz.ll b/test/CodeGen/X86/clz.ll index c16842a97ba..bcba9da1150 100644 --- a/test/CodeGen/X86/clz.ll +++ b/test/CodeGen/X86/clz.ll @@ -1,8 +1,10 @@ -; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck %s +; RUN: llc < %s -march=x86-64 -mcpu=yonah | FileCheck %s declare i32 @llvm.cttz.i32(i32, i1) +declare i8 @llvm.ctlz.i8(i8, i1) declare i16 @llvm.ctlz.i16(i16, i1) declare i32 @llvm.ctlz.i32(i32, i1) +declare i64 @llvm.ctlz.i64(i64, i1) define i32 @cttz_i32(i32 %x) { %tmp = call i32 @llvm.cttz.i32( i32 %x, i1 true ) @@ -13,10 +15,20 @@ define i32 @cttz_i32(i32 %x) { ; CHECK: ret } -define i16 @ctlz_i16(i16 %x, i16 %y) { +define i8 @ctlz_i8(i8 %x) { entry: - %tmp1 = add i16 %x, %y - %tmp2 = call i16 @llvm.ctlz.i16( i16 %tmp1, i1 true ) + %tmp2 = call i8 @llvm.ctlz.i8( i8 %x, i1 true ) + ret i8 %tmp2 +; CHECK: ctlz_i8: +; CHECK: bsrl +; CHECK-NOT: cmov +; CHECK: xorl $7, +; CHECK: ret +} + +define i16 @ctlz_i16(i16 %x) { +entry: + %tmp2 = call i16 @llvm.ctlz.i16( i16 %x, i1 true ) ret i16 %tmp2 ; CHECK: ctlz_i16: ; CHECK: bsrw @@ -35,6 +47,16 @@ define i32 @ctlz_i32(i32 %x) { ; CHECK: ret } +define i64 @ctlz_i64(i64 %x) { + %tmp = call i64 @llvm.ctlz.i64( i64 %x, i1 true ) + ret i64 %tmp +; CHECK: ctlz_i64: +; CHECK: bsrq +; CHECK-NOT: cmov +; CHECK: xorq $63, +; CHECK: ret +} + define i32 @ctlz_i32_cmov(i32 %n) { entry: ; Generate a cmov to handle zero inputs when necessary. -- 2.34.1