blob: e5d0a6affafa73ef10bb6c66cfca6038ffed2781 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc -mtriple=sparc -misched-postra -enable-post-misched < %s \
; RUN: | FileCheck %s --check-prefix=V8
; RUN: llc -mtriple=sparcv9 -misched-postra -enable-post-misched < %s \
; RUN: | FileCheck %s --check-prefix=V9
;; RESTORE switches to the caller's register window, so the add that reads the
;; loaded value in %i0 must not be moved after it.
define i32 @restore_boundary(ptr %p) nounwind {
; V8-LABEL: restore_boundary:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -96, %sp
; V8-NEXT: call g
; V8-NEXT: nop
; V8-NEXT: ld [%i0], %i0
; V8-NEXT: ret
; V8-NEXT: restore %i0, 1, %o0
;
; V9-LABEL: restore_boundary:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -176, %sp
; V9-NEXT: call g
; V9-NEXT: nop
; V9-NEXT: ld [%i0], %i0
; V9-NEXT: ret
; V9-NEXT: restore %i0, 1, %o0
call void @g()
%v = load i32, ptr %p
%x = add i32 %v, 1
ret i32 %x
}
;; The same for a tail call, where the add sets up the callee's argument.
define i32 @restore_boundary_tail_call(ptr %p, i32 %b) nounwind {
; V8-LABEL: restore_boundary_tail_call:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -96, %sp
; V8-NEXT: call g
; V8-NEXT: nop
; V8-NEXT: ld [%i0], %i0
; V8-NEXT: call h
; V8-NEXT: restore %i0, 1, %o0
;
; V9-LABEL: restore_boundary_tail_call:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -176, %sp
; V9-NEXT: call g
; V9-NEXT: nop
; V9-NEXT: ld [%i0], %i0
; V9-NEXT: call h
; V9-NEXT: restore %i0, 1, %o0
call void @g()
%v = load i32, ptr %p
%x = add i32 %v, 1
%r = tail call i32 @h(i32 %x, i32 %b)
ret i32 %r
}
;; A tail call from a leaf procedure saves %o7 in %g1 and has to restore it in
;; the delay slot of the call, since the call writes %o7. The multiplication
;; must not be moved after the restore, where it would take the delay slot.
define void @leaf_tail_call(ptr %p, ptr %q, i32 %c) nounwind {
; V8-LABEL: leaf_tail_call:
; V8: ! %bb.0:
; V8-NEXT: ld [%o0], %o0
; V8-NEXT: ld [%o1], %o1
; V8-NEXT: mov %o7, %g1
; V8-NEXT: smul %o0, %o1, %o1
; V8-NEXT: call ext
; V8-NEXT: mov %g1, %o7
;
; V9-LABEL: leaf_tail_call:
; V9: ! %bb.0:
; V9-NEXT: ld [%o0], %o0
; V9-NEXT: ldsw [%o1], %o1
; V9-NEXT: mov %o7, %g1
; V9-NEXT: sra %o0, 0, %o3
; V9-NEXT: mulx %o3, %o1, %o1
; V9-NEXT: call ext
; V9-NEXT: mov %g1, %o7
%x = load i32, ptr %p
%y = load i32, ptr %q
%z = mul i32 %x, %y
tail call void @ext(i32 %x, i32 %z, i32 %c)
ret void
}
declare void @g()
declare i32 @h(i32, i32)
declare void @ext(i32, i32, i32)