llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[RISCV] Unnecessary move of undefined with subregister liveness enabled

Open lukel97 opened this issue 2 years ago • 2 comments

define void @repeat_shuffle(<2 x double> %v, ptr noalias %q) {
  %w = shufflevector <2 x double> %v, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  store <4 x double> %w, ptr %q
  ret void
}

When compiled with llc -mattr=+v, there's an unnecessary vmv1r.v v13, v10 emitted, which copies an implicit def to v13.

repeat_shuffle:                         # @repeat_shuffle
	.cfi_startproc
# %bb.0:
	vmv2r.v	v12, v8
	vsetivli	zero, 4, e64, m2, ta, ma
	vmv1r.v	v13, v10
	vslideup.vi	v8, v12, 2
	vse64.v	v8, (a0)
	ret

Compiling with -riscv-enable-subreg-liveness=0 avoids this:

repeat_shuffle:                         # @repeat_shuffle
	.cfi_startproc
# %bb.0:
                                        # kill: def $v8 killed $v8 def $v8m2
	vsetivli	zero, 4, e64, m2, ta, ma
	vmv2r.v	v10, v8
	vslideup.vi	v10, v8, 2
	vse64.v	v10, (a0)
	ret

lukel97 avatar Jun 27 '23 15:06 lukel97

@llvm/issue-subscribers-backend-risc-v

llvmbot avatar Jun 27 '23 15:06 llvmbot

cc: @BeMg

topperc avatar Jun 28 '23 00:06 topperc

This patch fix it.

BeMg avatar Aug 02 '23 00:08 BeMg

Fixed via https://github.com/llvm/llvm-project/commit/1e86abc914bb

kito-cheng avatar Aug 02 '23 00:08 kito-cheng