; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 ; RUN: llc --mtriple=loongarch64 --frame-pointer=none --mattr=+lasx < %s | FileCheck %s ;; This test is checking that when a function allows stack realignment and ;; realignment needs were not detected before register allocation (at this ;; point, fp is not preserved), but realignment is required during register ;; allocation, the stack should not undergo realignment. ;; Ensure that the `bstrins.d $sp, $zero, n, 0` instruction is not generated. ;; n = log2(realign_size) - 1 %struct.S = type { [64 x i16] } define dso_local noundef signext i32 @main() nounwind { ; CHECK-LABEL: main: ; CHECK: # %bb.0: # %entry ; CHECK-NEXT: addi.d $sp, $sp, -288 ; CHECK-NEXT: st.d $ra, $sp, 280 # 8-byte Folded Spill ; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI0_0) ; CHECK-NEXT: xvld $xr0, $a0, %pc_lo12(.LCPI0_0) ; CHECK-NEXT: xvst $xr0, $sp, 112 # 32-byte Folded Spill ; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI0_1) ; CHECK-NEXT: xvld $xr1, $a0, %pc_lo12(.LCPI0_1) ; CHECK-NEXT: xvst $xr1, $sp, 80 # 32-byte Folded Spill ; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI0_2) ; CHECK-NEXT: xvld $xr2, $a0, %pc_lo12(.LCPI0_2) ; CHECK-NEXT: xvst $xr2, $sp, 48 # 32-byte Folded Spill ; CHECK-NEXT: pcalau12i $a0, %pc_hi20(.LCPI0_3) ; CHECK-NEXT: xvld $xr3, $a0, %pc_lo12(.LCPI0_3) ; CHECK-NEXT: xvst $xr3, $sp, 16 # 32-byte Folded Spill ; CHECK-NEXT: xvst $xr0, $sp, 152 ; CHECK-NEXT: xvst $xr1, $sp, 184 ; CHECK-NEXT: xvst $xr2, $sp, 216 ; CHECK-NEXT: xvst $xr3, $sp, 248 ; CHECK-NEXT: addi.d $a0, $sp, 152 ; CHECK-NEXT: pcaddu18i $ra, %call36(foo) ; CHECK-NEXT: jirl $ra, $ra, 0 ; CHECK-NEXT: xvld $xr0, $sp, 112 # 32-byte Folded Reload ; CHECK-NEXT: xvst $xr0, $sp, 152 ; CHECK-NEXT: xvld $xr0, $sp, 80 # 32-byte Folded Reload ; CHECK-NEXT: xvst $xr0, $sp, 184 ; CHECK-NEXT: xvld $xr0, $sp, 48 # 32-byte Folded Reload ; CHECK-NEXT: xvst $xr0, $sp, 216 ; CHECK-NEXT: xvld $xr0, $sp, 16 # 32-byte Folded Reload ; CHECK-NEXT: xvst $xr0, $sp, 248 ; CHECK-NEXT: addi.d $a0, $sp, 152 ; CHECK-NEXT: pcaddu18i $ra, %call36(bar) ; CHECK-NEXT: jirl $ra, $ra, 0 ; CHECK-NEXT: move $a0, $zero ; CHECK-NEXT: ld.d $ra, $sp, 280 # 8-byte Folded Reload ; CHECK-NEXT: addi.d $sp, $sp, 288 ; CHECK-NEXT: ret entry: %s = alloca %struct.S, align 2 call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %s) store <16 x i16> , ptr %s, align 2 %0 = getelementptr inbounds [64 x i16], ptr %s, i64 0, i64 16 store <16 x i16> , ptr %0, align 2 %1 = getelementptr inbounds [64 x i16], ptr %s, i64 0, i64 32 store <16 x i16> , ptr %1, align 2 %2 = getelementptr inbounds [64 x i16], ptr %s, i64 0, i64 48 store <16 x i16> , ptr %2, align 2 call void @foo(ptr noundef nonnull %s) store <16 x i16> , ptr %s, align 2 %3 = getelementptr inbounds [64 x i16], ptr %s, i64 0, i64 16 store <16 x i16> , ptr %3, align 2 %4 = getelementptr inbounds [64 x i16], ptr %s, i64 0, i64 32 store <16 x i16> , ptr %4, align 2 %5 = getelementptr inbounds [64 x i16], ptr %s, i64 0, i64 48 store <16 x i16> , ptr %5, align 2 call void @bar(ptr noundef nonnull %s) call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %s) ret i32 0 } declare void @foo(ptr nocapture noundef) declare void @bar(ptr nocapture noundef) declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)