Enable i16 to i32 promotion by default.
[oota-llvm.git] / test / CodeGen / X86 / h-registers-0.ll
1 ; RUN: llc < %s -march=x86-64 | FileCheck %s -check-prefix=X86-64
2 ; RUN: llc < %s -march=x86    | FileCheck %s -check-prefix=X86-32
3
4 ; Use h registers. On x86-64, codegen doesn't support general allocation
5 ; of h registers yet, due to x86 encoding complications.
6
7 define void @bar64(i64 inreg %x, i8* inreg %p) nounwind {
8 ; X86-64: bar64:
9 ; X86-64: shrq $8, %rdi
10 ; X86-64: incb %dil
11
12 ; X86-32: bar64:
13 ; X86-32: incb %ah
14   %t0 = lshr i64 %x, 8
15   %t1 = trunc i64 %t0 to i8
16   %t2 = add i8 %t1, 1
17   store i8 %t2, i8* %p
18   ret void
19 }
20
21 define void @bar32(i32 inreg %x, i8* inreg %p) nounwind {
22 ; X86-64: bar32:
23 ; X86-64: shrl $8, %edi
24 ; X86-64: incb %dil
25
26 ; X86-32: bar32:
27 ; X86-32: incb %ah
28   %t0 = lshr i32 %x, 8
29   %t1 = trunc i32 %t0 to i8
30   %t2 = add i8 %t1, 1
31   store i8 %t2, i8* %p
32   ret void
33 }
34
35 define void @bar16(i16 inreg %x, i8* inreg %p) nounwind {
36 ; X86-64: bar16:
37 ; X86-64: shrl $8, %edi
38 ; X86-64: incb %dil
39
40 ; X86-32: bar16:
41 ; X86-32: incb %ah
42   %t0 = lshr i16 %x, 8
43   %t1 = trunc i16 %t0 to i8
44   %t2 = add i8 %t1, 1
45   store i8 %t2, i8* %p
46   ret void
47 }
48
49 define i64 @qux64(i64 inreg %x) nounwind {
50 ; X86-64: qux64:
51 ; X86-64: movq %rdi, %rax
52 ; X86-64: movzbl %ah, %eax
53
54 ; X86-32: qux64:
55 ; X86-32: movzbl %ah, %eax
56   %t0 = lshr i64 %x, 8
57   %t1 = and i64 %t0, 255
58   ret i64 %t1
59 }
60
61 define i32 @qux32(i32 inreg %x) nounwind {
62 ; X86-64: qux32:
63 ; X86-64: movl %edi, %eax
64 ; X86-64: movzbl %ah, %eax
65
66 ; X86-32: qux32:
67 ; X86-32: movzbl %ah, %eax
68   %t0 = lshr i32 %x, 8
69   %t1 = and i32 %t0, 255
70   ret i32 %t1
71 }
72
73 define i16 @qux16(i16 inreg %x) nounwind {
74 ; X86-64: qux16:
75 ; X86-64: movl %edi, %eax
76 ; X86-64: movzbl %ah, %eax
77
78 ; X86-32: qux16:
79 ; X86-32: movzbl %ah, %eax
80   %t0 = lshr i16 %x, 8
81   ret i16 %t0
82 }