1 ; RUN: llc < %s -march=sparcv9 -mattr=+popc -disable-sparc-delay-filler -disable-sparc-leaf-proc | FileCheck %s
2 ; RUN: llc < %s -march=sparcv9 -mattr=+popc | FileCheck %s -check-prefix=OPT
3 ; RUN: llc %s -march=sparcv9 -mattr=+popc -filetype=null
11 define i64 @ret2(i64 %a, i64 %b) {
16 ; CHECK: sllx %i0, 7, %i0
20 ; OPT: sllx %o0, 7, %o0
21 define i64 @shl_imm(i64 %a) {
27 ; CHECK: srax %i0, %i1, %i0
31 ; OPT: srax %o0, %o1, %o0
32 define i64 @sra_reg(i64 %a, i64 %b) {
37 ; Immediate materialization. Many of these patterns could actually be merged
38 ; into the restore instruction:
40 ; restore %g0, %g0, %o0
48 define i64 @ret_imm0() {
53 ; CHECK: mov -4096, %i0
58 define i64 @ret_simm13() {
70 define i64 @ret_sethi() {
75 ; CHECK: sethi 4, [[R:%[goli][0-7]]]
76 ; CHECK: or [[R]], 1, %i0
79 ; OPT: sethi 4, [[R:%[go][0-7]]]
81 ; OPT: or [[R]], 1, %o0
83 define i64 @ret_sethi_or() {
88 ; CHECK: sethi 4, [[R:%[goli][0-7]]]
89 ; CHECK: xor [[R]], -4, %i0
92 ; OPT: sethi 4, [[R:%[go][0-7]]]
94 ; OPT: xor [[R]], -4, %o0
96 define i64 @ret_nimm33() {
103 define i64 @ret_bigimm() {
104 ret i64 6800754272627607872
108 ; CHECK: sethi 1048576
109 define i64 @ret_bigimm2() {
110 ret i64 4611686018427387904 ; 0x4000000000000000
114 ; CHECK: add %i0, %i1, [[R0:%[goli][0-7]]]
115 ; CHECK: sub [[R0]], %i2, [[R1:%[goli][0-7]]]
116 ; CHECK: andn [[R1]], %i0, %i0
117 define i64 @reg_reg_alu(i64 %x, i64 %y, i64 %z) {
126 ; CHECK: add %i0, -5, [[R0:%[goli][0-7]]]
127 ; CHECK: xor [[R0]], 2, %i0
128 define i64 @reg_imm_alu(i64 %x, i64 %y, i64 %z) {
143 define i64 @loads(ptr %p, ptr %q, ptr %r, ptr %s) {
144 %a = load i64, ptr %p
146 store i64 %ai, ptr %p
147 %b = load i32, ptr %q
148 %b2 = zext i32 %b to i64
149 %bi = trunc i64 %ai to i32
150 store i32 %bi, ptr %q
151 %c = load i32, ptr %r
152 %c2 = sext i32 %c to i64
153 store i64 %ai, ptr %p
154 %d = load i16, ptr %s
155 %d2 = sext i16 %d to i64
156 %di = trunc i64 %ai to i16
157 store i16 %di, ptr %s
159 %x1 = add i64 %a, %b2
160 %x2 = add i64 %c2, %d2
161 %x3 = add i64 %x1, %x2
166 ; CHECK: ldub [%i0], %i0
167 define i64 @load_bool(ptr %p) {
169 %b = zext i1 %a to i64
174 ; CHECK: ldx [%i0+8], [[R:%[goli][0-7]]]
175 ; CHECK: stx [[R]], [%i0+16]
176 ; CHECK: st [[R]], [%i1+-8]
177 ; CHECK: sth [[R]], [%i2+40]
178 ; CHECK: stb [[R]], [%i3+-20]
179 define void @stores(ptr %p, ptr %q, ptr %r, ptr %s) {
180 %p1 = getelementptr i64, ptr %p, i64 1
181 %p2 = getelementptr i64, ptr %p, i64 2
182 %pv = load i64, ptr %p1
183 store i64 %pv, ptr %p2
185 %q2 = getelementptr i32, ptr %q, i32 -2
186 %qv = trunc i64 %pv to i32
187 store i32 %qv, ptr %q2
189 %r2 = getelementptr i16, ptr %r, i16 20
190 %rv = trunc i64 %pv to i16
191 store i16 %rv, ptr %r2
193 %s2 = getelementptr i8, ptr %s, i8 -20
194 %sv = trunc i64 %pv to i8
195 store i8 %sv, ptr %s2
200 ; CHECK: promote_shifts
201 ; CHECK: ldub [%i0], [[R:%[goli][0-7]]]
202 ; CHECK: sll [[R]], [[R]], %i0
203 define i8 @promote_shifts(ptr %p) {
204 %L24 = load i8, ptr %p
205 %L32 = load i8, ptr %p
206 %B36 = shl i8 %L24, %L32
211 ; CHECK: mulx %i0, %i1, %i0
212 define i64 @multiply(i64 %a, i64 %b) {
217 ; CHECK: signed_divide
218 ; CHECK: sdivx %i0, %i1, %i0
219 define i64 @signed_divide(i64 %a, i64 %b) {
224 ; CHECK: unsigned_divide
225 ; CHECK: udivx %i0, %i1, %i0
226 define i64 @unsigned_divide(i64 %a, i64 %b) {
231 define void @access_fi() {
233 %b = alloca [32 x i8], align 1
234 %arraydecay = getelementptr inbounds [32 x i8], ptr %b, i64 0, i64 0
235 call void @g(ptr %arraydecay) #2
241 ; CHECK: expand_setcc
242 ; CHECK: movrgz %i0, 1,
243 define i32 @expand_setcc(i64 %a) {
244 %cond = icmp sle i64 %a, 0
245 %cast2 = zext i1 %cond to i32
246 %RV = sub i32 1, %cast2
253 define i64 @spill_i64(i64 %x) {
254 call void asm sideeffect "", "~{i0},~{i1},~{i2},~{i3},~{i4},~{i5},~{o0},~{o1},~{o2},~{o3},~{o4},~{o5},~{o7},~{l0},~{l1},~{l2},~{l3},~{l4},~{l5},~{l6},~{l7},~{g1},~{g2},~{g3},~{g4},~{g5},~{g6},~{g7}"()
258 ; CHECK: bitcast_i64_f64
261 define i64 @bitcast_i64_f64(double %x) {
262 %y = bitcast double %x to i64
266 ; CHECK: bitcast_f64_i64
269 define double @bitcast_f64_i64(i64 %x) {
270 %y = bitcast i64 %x to double
274 ; CHECK-LABEL: store_zero:
275 ; CHECK: stx %g0, [%i0]
276 ; CHECK: stx %g0, [%i1+8]
278 ; OPT-LABEL: store_zero:
279 ; OPT: stx %g0, [%o0]
280 ; OPT: stx %g0, [%o1+8]
281 define i64 @store_zero(ptr nocapture %a, ptr nocapture %b) {
283 store i64 0, ptr %a, align 8
284 %0 = getelementptr inbounds i64, ptr %b, i32 1
285 store i64 0, ptr %0, align 8
289 ; CHECK-LABEL: bit_ops
295 define i64 @bit_ops(i64 %arg) {
297 %0 = tail call i64 @llvm.ctpop.i64(i64 %arg)
298 %1 = tail call i64 @llvm.ctlz.i64(i64 %arg, i1 true)
299 %2 = tail call i64 @llvm.cttz.i64(i64 %arg, i1 true)
300 %3 = tail call i64 @llvm.bswap.i64(i64 %arg)
307 declare i64 @llvm.ctpop.i64(i64) nounwind readnone
308 declare i64 @llvm.ctlz.i64(i64, i1) nounwind readnone
309 declare i64 @llvm.cttz.i64(i64, i1) nounwind readnone
310 declare i64 @llvm.bswap.i64(i64) nounwind readnone