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, -64 27; RV32I-NEXT: sw ra, 60(sp) 28; RV32I-NEXT: sw s0, 56(sp) 29; RV32I-NEXT: sw s1, 52(sp) 30; RV32I-NEXT: sw s2, 48(sp) 31; RV32I-NEXT: sw s3, 44(sp) 32; RV32I-NEXT: sw s4, 40(sp) 33; RV32I-NEXT: sw s5, 36(sp) 34; RV32I-NEXT: sw s6, 32(sp) 35; RV32I-NEXT: sw s7, 28(sp) 36; RV32I-NEXT: sw s8, 24(sp) 37; RV32I-NEXT: sw s9, 20(sp) 38; RV32I-NEXT: sw s10, 16(sp) 39; RV32I-NEXT: sw s11, 12(sp) 40; RV32I-NEXT: lui s6, %hi(a) 41; RV32I-NEXT: lw a0, %lo(a)(s6) 42; RV32I-NEXT: beqz a0, .LBB0_11 43; RV32I-NEXT: # %bb.1: # %for.body.preheader 44; RV32I-NEXT: lui s2, %hi(l) 45; RV32I-NEXT: lui s3, %hi(k) 46; RV32I-NEXT: lui s4, %hi(j) 47; RV32I-NEXT: lui s5, %hi(i) 48; RV32I-NEXT: lui s1, %hi(d) 49; RV32I-NEXT: lui s0, %hi(e) 50; RV32I-NEXT: lui s7, %hi(f) 51; RV32I-NEXT: lui s8, %hi(g) 52; RV32I-NEXT: lui s9, %hi(h) 53; RV32I-NEXT: lui s10, %hi(c) 54; RV32I-NEXT: lui s11, %hi(b) 55; RV32I-NEXT: j .LBB0_3 56; RV32I-NEXT: .LBB0_2: # %for.inc 57; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 58; RV32I-NEXT: lw a0, %lo(a)(s6) 59; RV32I-NEXT: addi a0, a0, -1 60; RV32I-NEXT: sw a0, %lo(a)(s6) 61; RV32I-NEXT: beqz a0, .LBB0_11 62; RV32I-NEXT: .LBB0_3: # %for.body 63; RV32I-NEXT: # =>This Inner Loop Header: Depth=1 64; RV32I-NEXT: lw a1, %lo(l)(s2) 65; RV32I-NEXT: beqz a1, .LBB0_5 66; RV32I-NEXT: # %bb.4: # %if.then 67; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 68; RV32I-NEXT: lw a1, %lo(b)(s11) 69; RV32I-NEXT: lw a2, %lo(c)(s10) 70; RV32I-NEXT: lw a3, %lo(d)(s1) 71; RV32I-NEXT: lw a4, %lo(e)(s0) 72; RV32I-NEXT: addi a5, zero, 32 73; RV32I-NEXT: call foo 74; RV32I-NEXT: .LBB0_5: # %if.end 75; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 76; RV32I-NEXT: lw a0, %lo(k)(s3) 77; RV32I-NEXT: beqz a0, .LBB0_7 78; RV32I-NEXT: # %bb.6: # %if.then3 79; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 80; RV32I-NEXT: lw a0, %lo(b)(s11) 81; RV32I-NEXT: lw a1, %lo(c)(s10) 82; RV32I-NEXT: lw a2, %lo(d)(s1) 83; RV32I-NEXT: lw a3, %lo(e)(s0) 84; RV32I-NEXT: lw a4, %lo(f)(s7) 85; RV32I-NEXT: addi a5, zero, 64 86; RV32I-NEXT: call foo 87; RV32I-NEXT: .LBB0_7: # %if.end5 88; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 89; RV32I-NEXT: lw a0, %lo(j)(s4) 90; RV32I-NEXT: beqz a0, .LBB0_9 91; RV32I-NEXT: # %bb.8: # %if.then7 92; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 93; RV32I-NEXT: lw a0, %lo(c)(s10) 94; RV32I-NEXT: lw a1, %lo(d)(s1) 95; RV32I-NEXT: lw a2, %lo(e)(s0) 96; RV32I-NEXT: lw a3, %lo(f)(s7) 97; RV32I-NEXT: lw a4, %lo(g)(s8) 98; RV32I-NEXT: addi a5, zero, 32 99; RV32I-NEXT: call foo 100; RV32I-NEXT: .LBB0_9: # %if.end9 101; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 102; RV32I-NEXT: lw a0, %lo(i)(s5) 103; RV32I-NEXT: beqz a0, .LBB0_2 104; RV32I-NEXT: # %bb.10: # %if.then11 105; RV32I-NEXT: # in Loop: Header=BB0_3 Depth=1 106; RV32I-NEXT: lw a0, %lo(d)(s1) 107; RV32I-NEXT: lw a1, %lo(e)(s0) 108; RV32I-NEXT: lw a2, %lo(f)(s7) 109; RV32I-NEXT: lw a3, %lo(g)(s8) 110; RV32I-NEXT: lw a4, %lo(h)(s9) 111; RV32I-NEXT: addi a5, zero, 32 112; RV32I-NEXT: call foo 113; RV32I-NEXT: j .LBB0_2 114; RV32I-NEXT: .LBB0_11: # %for.end 115; RV32I-NEXT: addi a0, zero, 1 116; RV32I-NEXT: lw s11, 12(sp) 117; RV32I-NEXT: lw s10, 16(sp) 118; RV32I-NEXT: lw s9, 20(sp) 119; RV32I-NEXT: lw s8, 24(sp) 120; RV32I-NEXT: lw s7, 28(sp) 121; RV32I-NEXT: lw s6, 32(sp) 122; RV32I-NEXT: lw s5, 36(sp) 123; RV32I-NEXT: lw s4, 40(sp) 124; RV32I-NEXT: lw s3, 44(sp) 125; RV32I-NEXT: lw s2, 48(sp) 126; RV32I-NEXT: lw s1, 52(sp) 127; RV32I-NEXT: lw s0, 56(sp) 128; RV32I-NEXT: lw ra, 60(sp) 129; RV32I-NEXT: addi sp, sp, 64 130; RV32I-NEXT: ret 131entry: 132 %.pr = load i32, i32* @a, align 4 133 %tobool14 = icmp eq i32 %.pr, 0 134 br i1 %tobool14, label %for.end, label %for.body 135 136for.body: ; preds = %entry, %for.inc 137 %0 = phi i32 [ %dec, %for.inc ], [ %.pr, %entry ] 138 %1 = load i32, i32* @l, align 4 139 %tobool1 = icmp eq i32 %1, 0 140 br i1 %tobool1, label %if.end, label %if.then 141 142if.then: ; preds = %for.body 143 %2 = load i32, i32* @b, align 4 144 %3 = load i32, i32* @c, align 4 145 %4 = load i32, i32* @d, align 4 146 %5 = load i32, i32* @e, align 4 147 %call = tail call i32 @foo(i32 %0, i32 %2, i32 %3, i32 %4, i32 %5, i32 32) 148 br label %if.end 149 150if.end: ; preds = %for.body, %if.then 151 %6 = load i32, i32* @k, align 4 152 %tobool2 = icmp eq i32 %6, 0 153 br i1 %tobool2, label %if.end5, label %if.then3 154 155if.then3: ; preds = %if.end 156 %7 = load i32, i32* @b, align 4 157 %8 = load i32, i32* @c, align 4 158 %9 = load i32, i32* @d, align 4 159 %10 = load i32, i32* @e, align 4 160 %11 = load i32, i32* @f, align 4 161 %call4 = tail call i32 @foo(i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 64) 162 br label %if.end5 163 164if.end5: ; preds = %if.end, %if.then3 165 %12 = load i32, i32* @j, align 4 166 %tobool6 = icmp eq i32 %12, 0 167 br i1 %tobool6, label %if.end9, label %if.then7 168 169if.then7: ; preds = %if.end5 170 %13 = load i32, i32* @c, align 4 171 %14 = load i32, i32* @d, align 4 172 %15 = load i32, i32* @e, align 4 173 %16 = load i32, i32* @f, align 4 174 %17 = load i32, i32* @g, align 4 175 %call8 = tail call i32 @foo(i32 %13, i32 %14, i32 %15, i32 %16, i32 %17, i32 32) 176 br label %if.end9 177 178if.end9: ; preds = %if.end5, %if.then7 179 %18 = load i32, i32* @i, align 4 180 %tobool10 = icmp eq i32 %18, 0 181 br i1 %tobool10, label %for.inc, label %if.then11 182 183if.then11: ; preds = %if.end9 184 %19 = load i32, i32* @d, align 4 185 %20 = load i32, i32* @e, align 4 186 %21 = load i32, i32* @f, align 4 187 %22 = load i32, i32* @g, align 4 188 %23 = load i32, i32* @h, align 4 189 %call12 = tail call i32 @foo(i32 %19, i32 %20, i32 %21, i32 %22, i32 %23, i32 32) 190 br label %for.inc 191 192for.inc: ; preds = %if.end9, %if.then11 193 %24 = load i32, i32* @a, align 4 194 %dec = add nsw i32 %24, -1 195 store i32 %dec, i32* @a, align 4 196 %tobool = icmp eq i32 %dec, 0 197 br i1 %tobool, label %for.end, label %for.body 198 199for.end: ; preds = %for.inc, %entry 200 ret i32 1 201} 202 203declare i32 @foo(i32, i32, i32, i32, i32, i32) 204