• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -O1 -mtriple=riscv32 -verify-machineinstrs < %s \
3; RUN:   | FileCheck %s -check-prefix=RV32I
4
5@a = common global i32 0, align 4
6@l = common global i32 0, align 4
7@b = common global i32 0, align 4
8@c = common global i32 0, align 4
9@d = common global i32 0, align 4
10@e = common global i32 0, align 4
11@k = common global i32 0, align 4
12@f = common global i32 0, align 4
13@j = common global i32 0, align 4
14@g = common global i32 0, align 4
15@i = common global i32 0, align 4
16@h = common global i32 0, align 4
17
18; This test case benefits from codegen recognising that some values are
19; trivially rematerialisable, meaning they are recreated rather than saved to
20; the stack and restored. It creates high register pressure to force this
21; situation.
22
23define i32 @test() nounwind {
24; RV32I-LABEL: test:
25; RV32I:       # %bb.0: # %entry
26; RV32I-NEXT:    addi sp, sp, -48
27; RV32I-NEXT:    sw ra, 44(sp)
28; RV32I-NEXT:    sw s1, 40(sp)
29; RV32I-NEXT:    sw s2, 36(sp)
30; RV32I-NEXT:    sw s3, 32(sp)
31; RV32I-NEXT:    sw s4, 28(sp)
32; RV32I-NEXT:    sw s5, 24(sp)
33; RV32I-NEXT:    sw s6, 20(sp)
34; RV32I-NEXT:    sw s7, 16(sp)
35; RV32I-NEXT:    sw s8, 12(sp)
36; RV32I-NEXT:    sw s9, 8(sp)
37; RV32I-NEXT:    sw s10, 4(sp)
38; RV32I-NEXT:    sw s11, 0(sp)
39; RV32I-NEXT:    lui s3, %hi(a)
40; RV32I-NEXT:    lw a0, %lo(a)(s3)
41; RV32I-NEXT:    beqz a0, .LBB0_11
42; RV32I-NEXT:  # %bb.1: # %for.body.preheader
43; RV32I-NEXT:    lui s5, %hi(k)
44; RV32I-NEXT:    lui s6, %hi(j)
45; RV32I-NEXT:    lui s7, %hi(i)
46; RV32I-NEXT:    lui s9, %hi(g)
47; RV32I-NEXT:    lui s10, %hi(f)
48; RV32I-NEXT:    lui s1, %hi(e)
49; RV32I-NEXT:    lui s8, %hi(d)
50; RV32I-NEXT:    addi s11, zero, 32
51; RV32I-NEXT:    lui s2, %hi(c)
52; RV32I-NEXT:    lui s4, %hi(b)
53; RV32I-NEXT:  .LBB0_2: # %for.body
54; RV32I-NEXT:    # =>This Inner Loop Header: Depth=1
55; RV32I-NEXT:    lui a1, %hi(l)
56; RV32I-NEXT:    lw a1, %lo(l)(a1)
57; RV32I-NEXT:    beqz a1, .LBB0_4
58; RV32I-NEXT:  # %bb.3: # %if.then
59; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
60; RV32I-NEXT:    lw a4, %lo(e)(s1)
61; RV32I-NEXT:    lw a3, %lo(d)(s8)
62; RV32I-NEXT:    lw a2, %lo(c)(s2)
63; RV32I-NEXT:    lw a1, %lo(b)(s4)
64; RV32I-NEXT:    mv a5, s11
65; RV32I-NEXT:    call foo
66; RV32I-NEXT:  .LBB0_4: # %if.end
67; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
68; RV32I-NEXT:    lw a0, %lo(k)(s5)
69; RV32I-NEXT:    beqz a0, .LBB0_6
70; RV32I-NEXT:  # %bb.5: # %if.then3
71; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
72; RV32I-NEXT:    lw a4, %lo(f)(s10)
73; RV32I-NEXT:    lw a3, %lo(e)(s1)
74; RV32I-NEXT:    lw a2, %lo(d)(s8)
75; RV32I-NEXT:    lw a1, %lo(c)(s2)
76; RV32I-NEXT:    lw a0, %lo(b)(s4)
77; RV32I-NEXT:    addi a5, zero, 64
78; RV32I-NEXT:    call foo
79; RV32I-NEXT:  .LBB0_6: # %if.end5
80; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
81; RV32I-NEXT:    lw a0, %lo(j)(s6)
82; RV32I-NEXT:    beqz a0, .LBB0_8
83; RV32I-NEXT:  # %bb.7: # %if.then7
84; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
85; RV32I-NEXT:    lw a4, %lo(g)(s9)
86; RV32I-NEXT:    lw a3, %lo(f)(s10)
87; RV32I-NEXT:    lw a2, %lo(e)(s1)
88; RV32I-NEXT:    lw a1, %lo(d)(s8)
89; RV32I-NEXT:    lw a0, %lo(c)(s2)
90; RV32I-NEXT:    mv a5, s11
91; RV32I-NEXT:    call foo
92; RV32I-NEXT:  .LBB0_8: # %if.end9
93; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
94; RV32I-NEXT:    lw a0, %lo(i)(s7)
95; RV32I-NEXT:    beqz a0, .LBB0_10
96; RV32I-NEXT:  # %bb.9: # %if.then11
97; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
98; RV32I-NEXT:    lui a0, %hi(h)
99; RV32I-NEXT:    lw a4, %lo(h)(a0)
100; RV32I-NEXT:    lw a3, %lo(g)(s9)
101; RV32I-NEXT:    lw a2, %lo(f)(s10)
102; RV32I-NEXT:    lw a1, %lo(e)(s1)
103; RV32I-NEXT:    lw a0, %lo(d)(s8)
104; RV32I-NEXT:    mv a5, s11
105; RV32I-NEXT:    call foo
106; RV32I-NEXT:  .LBB0_10: # %for.inc
107; RV32I-NEXT:    # in Loop: Header=BB0_2 Depth=1
108; RV32I-NEXT:    lw a0, %lo(a)(s3)
109; RV32I-NEXT:    addi a0, a0, -1
110; RV32I-NEXT:    sw a0, %lo(a)(s3)
111; RV32I-NEXT:    bnez a0, .LBB0_2
112; RV32I-NEXT:  .LBB0_11: # %for.end
113; RV32I-NEXT:    addi a0, zero, 1
114; RV32I-NEXT:    lw s11, 0(sp)
115; RV32I-NEXT:    lw s10, 4(sp)
116; RV32I-NEXT:    lw s9, 8(sp)
117; RV32I-NEXT:    lw s8, 12(sp)
118; RV32I-NEXT:    lw s7, 16(sp)
119; RV32I-NEXT:    lw s6, 20(sp)
120; RV32I-NEXT:    lw s5, 24(sp)
121; RV32I-NEXT:    lw s4, 28(sp)
122; RV32I-NEXT:    lw s3, 32(sp)
123; RV32I-NEXT:    lw s2, 36(sp)
124; RV32I-NEXT:    lw s1, 40(sp)
125; RV32I-NEXT:    lw ra, 44(sp)
126; RV32I-NEXT:    addi sp, sp, 48
127; RV32I-NEXT:    ret
128entry:
129  %.pr = load i32, i32* @a, align 4
130  %tobool14 = icmp eq i32 %.pr, 0
131  br i1 %tobool14, label %for.end, label %for.body
132
133for.body:                                         ; preds = %entry, %for.inc
134  %0 = phi i32 [ %dec, %for.inc ], [ %.pr, %entry ]
135  %1 = load i32, i32* @l, align 4
136  %tobool1 = icmp eq i32 %1, 0
137  br i1 %tobool1, label %if.end, label %if.then
138
139if.then:                                          ; preds = %for.body
140  %2 = load i32, i32* @b, align 4
141  %3 = load i32, i32* @c, align 4
142  %4 = load i32, i32* @d, align 4
143  %5 = load i32, i32* @e, align 4
144  %call = tail call i32 @foo(i32 %0, i32 %2, i32 %3, i32 %4, i32 %5, i32 32) #3
145  br label %if.end
146
147if.end:                                           ; preds = %for.body, %if.then
148  %6 = load i32, i32* @k, align 4
149  %tobool2 = icmp eq i32 %6, 0
150  br i1 %tobool2, label %if.end5, label %if.then3
151
152if.then3:                                         ; preds = %if.end
153  %7 = load i32, i32* @b, align 4
154  %8 = load i32, i32* @c, align 4
155  %9 = load i32, i32* @d, align 4
156  %10 = load i32, i32* @e, align 4
157  %11 = load i32, i32* @f, align 4
158  %call4 = tail call i32 @foo(i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 64) #3
159  br label %if.end5
160
161if.end5:                                          ; preds = %if.end, %if.then3
162  %12 = load i32, i32* @j, align 4
163  %tobool6 = icmp eq i32 %12, 0
164  br i1 %tobool6, label %if.end9, label %if.then7
165
166if.then7:                                         ; preds = %if.end5
167  %13 = load i32, i32* @c, align 4
168  %14 = load i32, i32* @d, align 4
169  %15 = load i32, i32* @e, align 4
170  %16 = load i32, i32* @f, align 4
171  %17 = load i32, i32* @g, align 4
172  %call8 = tail call i32 @foo(i32 %13, i32 %14, i32 %15, i32 %16, i32 %17, i32 32) #3
173  br label %if.end9
174
175if.end9:                                          ; preds = %if.end5, %if.then7
176  %18 = load i32, i32* @i, align 4
177  %tobool10 = icmp eq i32 %18, 0
178  br i1 %tobool10, label %for.inc, label %if.then11
179
180if.then11:                                        ; preds = %if.end9
181  %19 = load i32, i32* @d, align 4
182  %20 = load i32, i32* @e, align 4
183  %21 = load i32, i32* @f, align 4
184  %22 = load i32, i32* @g, align 4
185  %23 = load i32, i32* @h, align 4
186  %call12 = tail call i32 @foo(i32 %19, i32 %20, i32 %21, i32 %22, i32 %23, i32 32) #3
187  br label %for.inc
188
189for.inc:                                          ; preds = %if.end9, %if.then11
190  %24 = load i32, i32* @a, align 4
191  %dec = add nsw i32 %24, -1
192  store i32 %dec, i32* @a, align 4
193  %tobool = icmp eq i32 %dec, 0
194  br i1 %tobool, label %for.end, label %for.body
195
196for.end:                                          ; preds = %for.inc, %entry
197  ret i32 1
198}
199
200declare i32 @foo(i32, i32, i32, i32, i32, i32)
201