Tests for 91103 and 91104.
[oota-llvm.git] / test / CodeGen / X86 / 3addr-16bit.ll
1 ; RUN: llc < %s -mtriple=i386-apple-darwin -asm-verbose=false   | FileCheck %s -check-prefix=32BIT
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -asm-verbose=false | FileCheck %s -check-prefix=64BIT
3
4 define zeroext i16 @t1(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
5 entry:
6 ; 32BIT:     t1:
7 ; 32BIT:     movw 20(%esp), %ax
8 ; 32BIT-NOT: movw %ax, %cx
9 ; 32BIT:     leal 1(%eax), %ecx
10
11 ; 64BIT:     t1:
12 ; 64BIT-NOT: movw %si, %ax
13 ; 64BIT:     leal 1(%rsi), %eax
14   %0 = icmp eq i16 %k, %c                         ; <i1> [#uses=1]
15   %1 = add i16 %k, 1                              ; <i16> [#uses=3]
16   br i1 %0, label %bb, label %bb1
17
18 bb:                                               ; preds = %entry
19   tail call void @foo(i16 zeroext %1) nounwind
20   ret i16 %1
21
22 bb1:                                              ; preds = %entry
23   ret i16 %1
24 }
25
26 define zeroext i16 @t2(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
27 entry:
28 ; 32BIT:     t2:
29 ; 32BIT:     movw 20(%esp), %ax
30 ; 32BIT-NOT: movw %ax, %cx
31 ; 32BIT:     leal -1(%eax), %ecx
32
33 ; 64BIT:     t2:
34 ; 64BIT-NOT: movw %si, %ax
35 ; 64BIT:     leal -1(%rsi), %eax
36   %0 = icmp eq i16 %k, %c                         ; <i1> [#uses=1]
37   %1 = add i16 %k, -1                             ; <i16> [#uses=3]
38   br i1 %0, label %bb, label %bb1
39
40 bb:                                               ; preds = %entry
41   tail call void @foo(i16 zeroext %1) nounwind
42   ret i16 %1
43
44 bb1:                                              ; preds = %entry
45   ret i16 %1
46 }
47
48 declare void @foo(i16 zeroext)
49
50 define zeroext i16 @t3(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
51 entry:
52 ; 32BIT:     t3:
53 ; 32BIT:     movw 20(%esp), %ax
54 ; 32BIT-NOT: movw %ax, %cx
55 ; 32BIT:     leal 2(%eax), %ecx
56
57 ; 64BIT:     t3:
58 ; 64BIT-NOT: movw %si, %ax
59 ; 64BIT:     leal 2(%rsi), %eax
60   %0 = add i16 %k, 2                              ; <i16> [#uses=3]
61   %1 = icmp eq i16 %k, %c                         ; <i1> [#uses=1]
62   br i1 %1, label %bb, label %bb1
63
64 bb:                                               ; preds = %entry
65   tail call void @foo(i16 zeroext %0) nounwind
66   ret i16 %0
67
68 bb1:                                              ; preds = %entry
69   ret i16 %0
70 }
71
72 define zeroext i16 @t4(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
73 entry:
74 ; 32BIT:     t4:
75 ; 32BIT:     movw 16(%esp), %ax
76 ; 32BIT:     movw 20(%esp), %cx
77 ; 32BIT-NOT: movw %cx, %dx
78 ; 32BIT:     leal (%ecx,%eax), %edx
79
80 ; 64BIT:     t4:
81 ; 64BIT-NOT: movw %si, %ax
82 ; 64BIT:     leal (%rsi,%rdi), %eax
83   %0 = add i16 %k, %c                             ; <i16> [#uses=3]
84   %1 = icmp eq i16 %k, %c                         ; <i1> [#uses=1]
85   br i1 %1, label %bb, label %bb1
86
87 bb:                                               ; preds = %entry
88   tail call void @foo(i16 zeroext %0) nounwind
89   ret i16 %0
90
91 bb1:                                              ; preds = %entry
92   ret i16 %0
93 }