[Sparc] Use addxcc/subxcc for adde/sube instead of addx/subx.
[oota-llvm.git] / test / CodeGen / SPARC / 2011-01-11-CC.ll
1 ; RUN: llc -march=sparc <%s | FileCheck %s -check-prefix=V8
2 ; RUN: llc -march=sparc -mattr=v9 <%s | FileCheck %s -check-prefix=V9
3
4
5 define i32 @test_addx(i64 %a, i64 %b, i64 %c) nounwind readnone noinline {
6 entry:
7 ; V8: addcc
8 ; V8-NOT: subcc
9 ; V8: addx
10 ; V9: addcc
11 ; V9-NOT: subcc
12 ; V9: addx
13 ; V9: mov{{e|ne}} %icc
14   %0 = add i64 %a, %b
15   %1 = icmp ugt i64 %0, %c
16   %2 = zext i1 %1 to i32
17   ret i32 %2
18 }
19
20
21 define i32 @test_select_int_icc(i32 %a, i32 %b, i32 %c) nounwind readnone noinline {
22 entry:
23 ; V8: test_select_int_icc
24 ; V8: cmp
25 ; V8: {{be|bne}}
26 ; V9: test_select_int_icc
27 ; V9: cmp
28 ; V9-NOT: {{be|bne}}
29 ; V9: mov{{e|ne}} %icc
30   %0 = icmp eq i32 %a, 0
31   %1 = select i1 %0, i32 %b, i32 %c
32   ret i32 %1
33 }
34
35
36 define float @test_select_fp_icc(i32 %a, float %f1, float %f2) nounwind readnone noinline {
37 entry:
38 ; V8: test_select_fp_icc
39 ; V8: cmp
40 ; V8: {{be|bne}}
41 ; V9: test_select_fp_icc
42 ; V9: cmp
43 ; V9-NOT: {{be|bne}}
44 ; V9: fmovs{{e|ne}} %icc
45   %0 = icmp eq i32 %a, 0
46   %1 = select i1 %0, float %f1, float %f2
47   ret float %1
48 }
49
50 define double @test_select_dfp_icc(i32 %a, double %f1, double %f2) nounwind readnone noinline {
51 entry:
52 ; V8: test_select_dfp_icc
53 ; V8: cmp
54 ; V8: {{be|bne}}
55 ; V9: test_select_dfp_icc
56 ; V9: cmp
57 ; V9-NOT: {{be|bne}}
58 ; V9: fmovd{{e|ne}} %icc
59   %0 = icmp eq i32 %a, 0
60   %1 = select i1 %0, double %f1, double %f2
61   ret double %1
62 }
63
64 define i32 @test_select_int_fcc(float %f, i32 %a, i32 %b) nounwind readnone noinline {
65 entry:
66 ;V8-LABEL: test_select_int_fcc:
67 ;V8: fcmps
68 ;V8: {{fbe|fbne}}
69 ;V9-LABEL: test_select_int_fcc:
70 ;V9: fcmps
71 ;V9-NOT: {{fbe|fbne}}
72 ;V9: mov{{e|ne}} %fcc0
73   %0 = fcmp une float %f, 0.000000e+00
74   %a.b = select i1 %0, i32 %a, i32 %b
75   ret i32 %a.b
76 }
77
78
79 define float @test_select_fp_fcc(float %f, float %f1, float %f2) nounwind readnone noinline {
80 entry:
81 ;V8-LABEL: test_select_fp_fcc:
82 ;V8: fcmps
83 ;V8: {{fbe|fbne}}
84 ;V9-LABEL: test_select_fp_fcc:
85 ;V9: fcmps
86 ;V9-NOT: {{fbe|fbne}}
87 ;V9: fmovs{{e|ne}} %fcc0
88   %0 = fcmp une float %f, 0.000000e+00
89   %1 = select i1 %0, float %f1, float %f2
90   ret float %1
91 }
92
93 define double @test_select_dfp_fcc(double %f, double %f1, double %f2) nounwind readnone noinline {
94 entry:
95 ;V8-LABEL: test_select_dfp_fcc:
96 ;V8: fcmpd
97 ;V8: {{fbne|fbe}}
98 ;V9-LABEL: test_select_dfp_fcc:
99 ;V9: fcmpd
100 ;V9-NOT: {{fbne|fbe}}
101 ;V9: fmovd{{e|ne}} %fcc0
102   %0 = fcmp une double %f, 0.000000e+00
103   %1 = select i1 %0, double %f1, double %f2
104   ret double %1
105 }
106
107 define i32 @test_float_cc(double %a, double %b, i32 %c, i32 %d) {
108 entry:
109 ; V8-LABEL: test_float_cc
110 ; V8:       fcmpd
111 ; V8:       {{fbl|fbuge}} .LBB
112 ; V8:       fcmpd
113 ; V8:       {{fbule|fbg}} .LBB
114
115 ; V9-LABEL: test_float_cc
116 ; V9:       fcmpd
117 ; V9:       {{fbl|fbuge}} .LBB
118 ; V9:       fcmpd
119 ; V9:       {{fbule|fbg}} .LBB
120
121    %0 = fcmp uge double %a, 0.000000e+00
122    br i1 %0, label %loop, label %loop.2
123
124 loop:
125    %1 = icmp eq i32 %c, 10
126    br i1 %1, label %loop, label %exit.0
127
128 loop.2:
129    %2 = fcmp ogt double %b, 0.000000e+00
130    br i1 %2, label %exit.1, label %loop
131
132 exit.0:
133    ret i32 0
134
135 exit.1:
136    ret i32 1
137 }
138
139 ; V8-LABEL: test_adde_sube
140 ; V8:       addcc
141 ; V8:       addxcc
142 ; V8:       addxcc
143 ; V8:       addxcc
144 ; V8:       subcc
145 ; V8:       subxcc
146 ; V8:       subxcc
147 ; V8:       subxcc
148
149
150 ; V9-LABEL: test_adde_sube
151 ; V9:       addcc
152 ; V9:       addxcc
153 ; V9:       addxcc
154 ; V9:       addxcc
155 ; V9:       subcc
156 ; V9:       subxcc
157 ; V9:       subxcc
158 ; V9:       subxcc
159
160
161 define void @test_adde_sube(i8* %a, i8* %b, i8* %sum, i8* %diff) {
162 entry:
163    %0 = bitcast i8* %a to i128*
164    %1 = bitcast i8* %b to i128*
165    %2 = load i128* %0
166    %3 = load i128* %1
167    %4 = add i128 %2, %3
168    %5 = bitcast i8* %sum to i128*
169    store i128 %4, i128* %5
170    tail call void asm sideeffect "", "=*m,*m"(i128 *%0, i128* %5) nounwind
171    %6 = load i128* %0
172    %7 = sub i128 %2, %6
173    %8 = bitcast i8* %diff to i128*
174    store i128 %7, i128* %8
175    ret void
176 }