aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/RISCV
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2024-03-26 21:37:19 -0700
committerGitHub <noreply@github.com>2024-03-26 21:37:19 -0700
commit8a9c1701704182d551bf9df1ff43363db56caab4 (patch)
treee7063646bc0b4de8a163a82ec8d467de2d28be98 /llvm/test/CodeGen/RISCV
parentecf6bb2b4dbd26bbff2cee79db010369faa2fe90 (diff)
downloadllvm-8a9c1701704182d551bf9df1ff43363db56caab4.zip
llvm-8a9c1701704182d551bf9df1ff43363db56caab4.tar.gz
llvm-8a9c1701704182d551bf9df1ff43363db56caab4.tar.bz2
[RISCV] Align stack size down to a multiple of 16 before using cm.push/pop. (#86073)
This an alternative to #84935 to fix the miscompile, but not be optimal. The immediate for cm.push/pop must be a multiple of 16. For RVE, it might not be. It's not easy to increase the stack size without messing up cfa directives and maybe other things. This patch rounds the stack size down to a multiple of 16 before clamping it to 48. This causes an extra addi to be emitted to handle the remainder. Once this commited, I can commit #84989 to add verification for these instructions being generated with valid offsets.
Diffstat (limited to 'llvm/test/CodeGen/RISCV')
-rw-r--r--llvm/test/CodeGen/RISCV/zcmp-additional-stack.ll6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/RISCV/zcmp-additional-stack.ll b/llvm/test/CodeGen/RISCV/zcmp-additional-stack.ll
index e5c2e01..73ace20 100644
--- a/llvm/test/CodeGen/RISCV/zcmp-additional-stack.ll
+++ b/llvm/test/CodeGen/RISCV/zcmp-additional-stack.ll
@@ -3,7 +3,8 @@
define ptr @func(ptr %s, i32 %_c, ptr %incdec.ptr, i1 %0, i8 %conv14) #0 {
; RV32-LABEL: func:
; RV32: # %bb.0: # %entry
-; RV32-NEXT: cm.push {ra, s0-s1}, -24
+; RV32-NEXT: cm.push {ra, s0-s1}, -16
+; RV32-NEXT: addi sp, sp, -8
; RV32-NEXT: .cfi_def_cfa_offset 24
; RV32-NEXT: .cfi_offset ra, -12
; RV32-NEXT: .cfi_offset s0, -8
@@ -31,7 +32,8 @@ define ptr @func(ptr %s, i32 %_c, ptr %incdec.ptr, i1 %0, i8 %conv14) #0 {
; RV32-NEXT: lw a0, 4(sp) # 4-byte Folded Reload
; RV32-NEXT: sb a0, 0(s0)
; RV32-NEXT: mv a0, s1
-; RV32-NEXT: cm.popret {ra, s0-s1}, 24
+; RV32-NEXT: addi sp, sp, 8
+; RV32-NEXT: cm.popret {ra, s0-s1}, 16
entry:
br label %while.body