RISC-V: Fix bug of AVL propagation PASS

Message ID 20231102113023.2225297-1-juzhe.zhong@rivai.ai
State Unresolved
Headers
Series RISC-V: Fix bug of AVL propagation PASS |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

juzhe.zhong@rivai.ai Nov. 2, 2023, 11:30 a.m. UTC
  A run FAIL suddenly shows up today to me:
FAIL: gcc.target/riscv/rvv/autovec/gather-scatter/mask_gather_load_run-11.c execution test

that I didn't have before.

After investigation, I realize that there is a bug in AVL propagtion PASS.

gcc/ChangeLog:

	* config/riscv/riscv-avlprop.cc (pass_avlprop::get_vlmax_ta_preferred_avl): Don't allow non-real insn AVL propation.

---
 gcc/config/riscv/riscv-avlprop.cc | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Robin Dapp Nov. 2, 2023, 11:34 a.m. UTC | #1
LGTM.

Regards
 Robin
  
Li, Pan2 Nov. 2, 2023, 11:44 a.m. UTC | #2
Committed, thanks Robin.

Pan

-----Original Message-----
From: Robin Dapp <rdapp.gcc@gmail.com> 
Sent: Thursday, November 2, 2023 7:34 PM
To: Juzhe-Zhong <juzhe.zhong@rivai.ai>; gcc-patches@gcc.gnu.org
Cc: rdapp.gcc@gmail.com; kito.cheng@gmail.com; kito.cheng@sifive.com; jeffreyalaw@gmail.com
Subject: Re: [PATCH] RISC-V: Fix bug of AVL propagation PASS

LGTM.

Regards
 Robin
  

Patch

diff --git a/gcc/config/riscv/riscv-avlprop.cc b/gcc/config/riscv/riscv-avlprop.cc
index bec1e3c715a..1dfaa8742da 100644
--- a/gcc/config/riscv/riscv-avlprop.cc
+++ b/gcc/config/riscv/riscv-avlprop.cc
@@ -308,6 +308,13 @@  pass_avlprop::get_vlmax_ta_preferred_avl (insn_info *insn) const
 	      def_info *def2 = dl.prev_def (use_insn);
 	      if (!def1 || !def2 || def1 != def2)
 		return NULL_RTX;
+	      /* For vectorized codes, we always use SELECT_VL/MIN_EXPR to
+		 calculate the loop len at the header of the loop.
+		 We only allow AVL propagation for real instruction for now.
+		 TODO: We may enhance it for intrinsic codes if it is necessary.
+	      */
+	      if (!def1->insn ()->is_real ())
+		return NULL_RTX;
 
 	      /* FIXME: We only all AVL propation within a block which should
 		 be totally enough for vectorized codes.