public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Fix ICE in riscv vector costs
@ 2024-03-07  5:54 demin.han
  2024-03-07  7:18 ` juzhe.zhong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: demin.han @ 2024-03-07  5:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: juzhe.zhong, kito.cheng, pan2.li, jeffreyalaw

The following code can result in ICE:
-march=rv64gcv_zba_zbb --param riscv-autovec-lmul=dynamic -O3

char *jpeg_difference7_input_buf;
void jpeg_difference7(int *diff_buf) {
  unsigned width;
  int samp, Rb;
  while (--width) {
    Rb = samp = *jpeg_difference7_input_buf;
    *diff_buf++ = -(int)(samp + (long)Rb >> 1);
  }
}

One biggest_mode update missed in one branch and trigger assertion fail.
gcc_assert (biggest_size >= mode_size);

Tested On RV64 and no regression.

gcc/ChangeLog:

	* config/riscv/riscv-vector-costs.cc: Fix ICE

Signed-off-by: demin.han <demin.han@starfivetech.com>
---
 gcc/config/riscv/riscv-vector-costs.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/config/riscv/riscv-vector-costs.cc b/gcc/config/riscv/riscv-vector-costs.cc
index 7c9840df4e9..f13a1296b31 100644
--- a/gcc/config/riscv/riscv-vector-costs.cc
+++ b/gcc/config/riscv/riscv-vector-costs.cc
@@ -413,6 +413,8 @@ compute_local_live_ranges (
 				  auto *r = get_live_range (live_ranges, arg);
 				  gcc_assert (r);
 				  (*r).second = MAX (point, (*r).second);
+				  biggest_mode = get_biggest_mode (
+				    biggest_mode, TYPE_MODE (TREE_TYPE (arg)));
 				}
 			    }
 			  else
-- 
2.44.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-07  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-07  5:54 [PATCH] RISC-V: Fix ICE in riscv vector costs demin.han
2024-03-07  7:18 ` juzhe.zhong
2024-03-07  7:19 ` juzhe.zhong
2024-03-07  7:39   ` Demin Han
2024-03-07  7:52     ` 回复: " juzhe.zhong
2024-03-07  8:32 ` [PATCH v2] " demin.han
2024-03-07  8:36   ` juzhe.zhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).