From 133ab9a8c82a31549f060da33fd7e14f1d7f39fd Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Fri, 28 Jun 2024 14:02:59 +0800 Subject: [PATCH] [RISCV] Add test for extending AVL live range across blocks. NFC This adds a separate test case for an existing issue fixed in #96200, where we failing to extend the live range of an AVL when inserting a vsetvli if the AVL was from a different block. --- .../RISCV/rvv/vsetvli-insert-crossbb.ll | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll b/llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll index 5a6364967eba2..d984e266d7658 100644 --- a/llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll @@ -1036,3 +1036,22 @@ declare @llvm.riscv.vadd.mask.nxv4i32.nxv4i32( , i64, i64); + +; Normally a pseudo's AVL is already live in its block, so it will already be +; live where we're inserting the vsetvli, before the pseudo. In some cases the +; AVL can be from a predecessor block, so make sure we extend its live range +; across blocks. +define @cross_block_avl_extend(i64 %avl, %a, %b) { +entry: + ; Get the output vl from a vsetvli + %vl = call i64 @llvm.riscv.vsetvli.i64(i64 %avl, i64 2, i64 0) + ; Force a vsetvli toggle so we need to insert a new vsetvli in exit + %d = call @llvm.riscv.vadd.nxv2i32( undef, %a, %b, i64 1) + br label %exit +exit: + ; The use of the vl from the vsetvli will be replaced with its %avl because + ; VLMAX is the same. So %avl, which was previously only live in %entry, will + ; need to be extended down toe %exit. + %c = call @llvm.riscv.vadd.nxv2i32( undef, %a, %d, i64 %vl) + ret %c +}