Issue 55396
Summary [riscv] Reload of vlenb during frame setup/teardown with scalable vector alloca
Labels backend:RISC-V, llvm:codegen, performance
Assignees
Reporter preames
    Noticed this while looking at something unrelated.  We're reading vlenb twice whereas this should effectively be a constant for a given platform.  

```
$ cat rvv-aligned-alloca.ll 
declare void @callee(<vscale x 1 x i8>* %p)

define void @caller() {
  %a = alloca <vscale x 1 x i8>
  call void @callee(<vscale x 1 x i8>* %a)
  ret void
}

$ ./opt -S -O3 rvv-aligned-alloca.ll | ./llc -O3 -march=riscv64 -mattr=+v
	.text
	.attribute	4, 16
	.attribute	5, "rv64i2p0_f2p0_d2p0_v1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0"
	.file	"rvv-aligned-alloca.ll"
	.globl	caller                          # -- Begin function caller
	.p2align	2
	.type	caller,@function
caller:                                 # @caller
	.cfi_startproc
# %bb.0:
	addi	sp, sp, -16
	.cfi_def_cfa_offset 16
	sd	ra, 8(sp)                       # 8-byte Folded Spill
	.cfi_offset ra, -8
	csrr	a0, vlenb
	sub	sp, sp, a0
	addi	a0, sp, 8
	call	callee@plt
	csrr	a0, vlenb
	add	sp, sp, a0
	ld	ra, 8(sp)                       # 8-byte Folded Reload
	addi	sp, sp, 16
	ret
.Lfunc_end0:
	.size	caller, .Lfunc_end0-caller
	.cfi_endproc
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to