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