1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -march=sparc   < %s | FileCheck %s --check-prefix=V8
3; RUN: llc -march=sparcv9 < %s | FileCheck %s --check-prefix=SPARC64
4
5; (this should ideally be doing "add 4+7; and -8", instead of
6;  "add 7; and -8; add 8"; see comments in LowerDYNAMIC_STACKALLOC)
7
8define void @variable_alloca_with_adj_call_stack(i32 %num) {
9; V8-LABEL: variable_alloca_with_adj_call_stack:
10; V8:         .cfi_startproc
11; V8-NEXT:  ! %bb.0: ! %entry
12; V8-NEXT:    save %sp, -96, %sp
13; V8-NEXT:    .cfi_def_cfa_register %fp
14; V8-NEXT:    .cfi_window_save
15; V8-NEXT:    .cfi_register %o7, %i7
16; V8-NEXT:    add %i0, 7, %i0
17; V8-NEXT:    and %i0, -8, %i0
18; V8-NEXT:    sub %sp, %i0, %i0
19; V8-NEXT:    add %i0, -8, %sp
20; V8-NEXT:    add %i0, 88, %o0
21; V8-NEXT:    add %sp, -16, %sp
22; V8-NEXT:    st %o0, [%sp+104]
23; V8-NEXT:    st %o0, [%sp+100]
24; V8-NEXT:    st %o0, [%sp+96]
25; V8-NEXT:    st %o0, [%sp+92]
26; V8-NEXT:    mov %o0, %o1
27; V8-NEXT:    mov %o0, %o2
28; V8-NEXT:    mov %o0, %o3
29; V8-NEXT:    mov %o0, %o4
30; V8-NEXT:    call foo
31; V8-NEXT:    mov %o0, %o5
32; V8-NEXT:    add %sp, 16, %sp
33; V8-NEXT:    ret
34; V8-NEXT:    restore
35;
36; SPARC64-LABEL: variable_alloca_with_adj_call_stack:
37; SPARC64:         .cfi_startproc
38; SPARC64-NEXT:  ! %bb.0: ! %entry
39; SPARC64-NEXT:    save %sp, -128, %sp
40; SPARC64-NEXT:    .cfi_def_cfa_register %fp
41; SPARC64-NEXT:    .cfi_window_save
42; SPARC64-NEXT:    .cfi_register %o7, %i7
43; SPARC64-NEXT:    srl %i0, 0, %i0
44; SPARC64-NEXT:    add %i0, 15, %i0
45; SPARC64-NEXT:    sethi 4194303, %i1
46; SPARC64-NEXT:    or %i1, 1008, %i1
47; SPARC64-NEXT:    sethi 0, %i2
48; SPARC64-NEXT:    or %i2, 1, %i2
49; SPARC64-NEXT:    sllx %i2, 32, %i2
50; SPARC64-NEXT:    or %i2, %i1, %i1
51; SPARC64-NEXT:    and %i0, %i1, %i0
52; SPARC64-NEXT:    sub %sp, %i0, %i0
53; SPARC64-NEXT:    add %i0, 2175, %o0
54; SPARC64-NEXT:    mov %i0, %sp
55; SPARC64-NEXT:    add %sp, -80, %sp
56; SPARC64-NEXT:    stx %o0, [%sp+2247]
57; SPARC64-NEXT:    stx %o0, [%sp+2239]
58; SPARC64-NEXT:    stx %o0, [%sp+2231]
59; SPARC64-NEXT:    stx %o0, [%sp+2223]
60; SPARC64-NEXT:    mov %o0, %o1
61; SPARC64-NEXT:    mov %o0, %o2
62; SPARC64-NEXT:    mov %o0, %o3
63; SPARC64-NEXT:    mov %o0, %o4
64; SPARC64-NEXT:    call foo
65; SPARC64-NEXT:    mov %o0, %o5
66; SPARC64-NEXT:    add %sp, 80, %sp
67; SPARC64-NEXT:    ret
68; SPARC64-NEXT:    restore
69entry:
70  %0 = alloca i8, i32 %num, align 8
71  call void @foo(i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0)
72  ret void
73}
74
75declare void @foo(i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*);
76