* [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
* Re: [PATCH] RISC-V: Fix ICE in riscv vector costs
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 8:32 ` [PATCH v2] " demin.han
2 siblings, 0 replies; 7+ messages in thread
From: juzhe.zhong @ 2024-03-07 7:18 UTC (permalink / raw)
To: demin.han, gcc-patches; +Cc: kito.cheng, pan2.li, jeffreyalaw
[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]
LGTM.
juzhe.zhong@rivai.ai
From: demin.han
Date: 2024-03-07 13:54
To: gcc-patches
CC: juzhe.zhong; kito.cheng; pan2.li; jeffreyalaw
Subject: [PATCH] RISC-V: Fix ICE in riscv vector costs
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
* Re: [PATCH] RISC-V: Fix ICE in riscv vector costs
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 8:32 ` [PATCH v2] " demin.han
2 siblings, 1 reply; 7+ messages in thread
From: juzhe.zhong @ 2024-03-07 7:19 UTC (permalink / raw)
To: demin.han, gcc-patches; +Cc: kito.cheng, pan2.li, jeffreyalaw
[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]
Could you plz add testcase ? I just noticed you didn't append a testcase (jpeg) in this patch.
juzhe.zhong@rivai.ai
From: demin.han
Date: 2024-03-07 13:54
To: gcc-patches
CC: juzhe.zhong; kito.cheng; pan2.li; jeffreyalaw
Subject: [PATCH] RISC-V: Fix ICE in riscv vector costs
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
* RE: [PATCH] RISC-V: Fix ICE in riscv vector costs
2024-03-07 7:19 ` juzhe.zhong
@ 2024-03-07 7:39 ` Demin Han
2024-03-07 7:52 ` 回复: " juzhe.zhong
0 siblings, 1 reply; 7+ messages in thread
From: Demin Han @ 2024-03-07 7:39 UTC (permalink / raw)
To: juzhe.zhong, gcc-patches; +Cc: kito.cheng, pan2.li, jeffreyalaw
[-- Attachment #1: Type: text/plain, Size: 2237 bytes --]
OK.
Which is better for testcase name?
1. ice-biggestmode.c or
2. Report a bug and name the testcase with PR id
From: juzhe.zhong@rivai.ai <juzhe.zhong@rivai.ai>
Sent: 2024年3月7日 15:20
To: Demin Han <demin.han@starfivetech.com>; gcc-patches <gcc-patches@gcc.gnu.org>
Cc: kito.cheng <kito.cheng@gmail.com>; pan2.li <pan2.li@intel.com>; jeffreyalaw <jeffreyalaw@gmail.com>
Subject: Re: [PATCH] RISC-V: Fix ICE in riscv vector costs
Could you plz add testcase ? I just noticed you didn't append a testcase (jpeg) in this patch.
________________________________
juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai>
From: demin.han<mailto:demin.han@starfivetech.com>
Date: 2024-03-07 13:54
To: gcc-patches<mailto:gcc-patches@gcc.gnu.org>
CC: juzhe.zhong<mailto:juzhe.zhong@rivai.ai>; kito.cheng<mailto:kito.cheng@gmail.com>; pan2.li<mailto:pan2.li@intel.com>; jeffreyalaw<mailto:jeffreyalaw@gmail.com>
Subject: [PATCH] RISC-V: Fix ICE in riscv vector costs
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<mailto: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
* 回复: RE: [PATCH] RISC-V: Fix ICE in riscv vector costs
2024-03-07 7:39 ` Demin Han
@ 2024-03-07 7:52 ` juzhe.zhong
0 siblings, 0 replies; 7+ messages in thread
From: juzhe.zhong @ 2024-03-07 7:52 UTC (permalink / raw)
To: demin.han, gcc-patches; +Cc: kito.cheng, pan2.li, jeffreyalaw
[-- Attachment #1: Type: text/plain, Size: 2232 bytes --]
I suggest open an PR with a PR id.
juzhe.zhong@rivai.ai
发件人: Demin Han
发送时间: 2024-03-07 15:39
收件人: juzhe.zhong@rivai.ai; gcc-patches
抄送: kito.cheng; pan2.li; jeffreyalaw
主题: RE: [PATCH] RISC-V: Fix ICE in riscv vector costs
OK.
Which is better for testcase name?
1. ice-biggestmode.c or
2. Report a bug and name the testcase with PR id
From: juzhe.zhong@rivai.ai <juzhe.zhong@rivai.ai>
Sent: 2024年3月7日 15:20
To: Demin Han <demin.han@starfivetech.com>; gcc-patches <gcc-patches@gcc.gnu.org>
Cc: kito.cheng <kito.cheng@gmail.com>; pan2.li <pan2.li@intel.com>; jeffreyalaw <jeffreyalaw@gmail.com>
Subject: Re: [PATCH] RISC-V: Fix ICE in riscv vector costs
Could you plz add testcase ? I just noticed you didn't append a testcase (jpeg) in this patch.
juzhe.zhong@rivai.ai
From: demin.han
Date: 2024-03-07 13:54
To: gcc-patches
CC: juzhe.zhong; kito.cheng; pan2.li; jeffreyalaw
Subject: [PATCH] RISC-V: Fix ICE in riscv vector costs
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
* [PATCH v2] RISC-V: Fix ICE in riscv vector costs
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 8:32 ` demin.han
2024-03-07 8:36 ` juzhe.zhong
2 siblings, 1 reply; 7+ messages in thread
From: demin.han @ 2024-03-07 8:32 UTC (permalink / raw)
To: gcc-patches; +Cc: juzhe.zhong, kito.cheng, pan2.li, jeffreyalaw
The following code can result in ICE:
-march=rv64gcv --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.
PR 114264
gcc/ChangeLog:
* config/riscv/riscv-vector-costs.cc: Fix ICE
gcc/testsuite/ChangeLog:
* gcc.dg/vect/costmodel/riscv/rvv/pr114264.c: New test.
Signed-off-by: demin.han <demin.han@starfivetech.com>
---
gcc/config/riscv/riscv-vector-costs.cc | 2 ++
.../gcc.dg/vect/costmodel/riscv/rvv/pr114264.c | 15 +++++++++++++++
2 files changed, 17 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c
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
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c
new file mode 100644
index 00000000000..7853f292af7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param=riscv-autovec-lmul=dynamic" } */
+
+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);
+ }
+}
--
2.44.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] RISC-V: Fix ICE in riscv vector costs
2024-03-07 8:32 ` [PATCH v2] " demin.han
@ 2024-03-07 8:36 ` juzhe.zhong
0 siblings, 0 replies; 7+ messages in thread
From: juzhe.zhong @ 2024-03-07 8:36 UTC (permalink / raw)
To: demin.han, gcc-patches; +Cc: kito.cheng, pan2.li, jeffreyalaw
[-- Attachment #1: Type: text/plain, Size: 2475 bytes --]
LGTM except a nit comment:
PR 114264 -> PR target/114264
No need to send V3, just commit it with this change.
juzhe.zhong@rivai.ai
From: demin.han
Date: 2024-03-07 16:32
To: gcc-patches
CC: juzhe.zhong; kito.cheng; pan2.li; jeffreyalaw
Subject: [PATCH v2] RISC-V: Fix ICE in riscv vector costs
The following code can result in ICE:
-march=rv64gcv --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.
PR 114264
gcc/ChangeLog:
* config/riscv/riscv-vector-costs.cc: Fix ICE
gcc/testsuite/ChangeLog:
* gcc.dg/vect/costmodel/riscv/rvv/pr114264.c: New test.
Signed-off-by: demin.han <demin.han@starfivetech.com>
---
gcc/config/riscv/riscv-vector-costs.cc | 2 ++
.../gcc.dg/vect/costmodel/riscv/rvv/pr114264.c | 15 +++++++++++++++
2 files changed, 17 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c
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
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c
new file mode 100644
index 00000000000..7853f292af7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114264.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param=riscv-autovec-lmul=dynamic" } */
+
+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);
+ }
+}
--
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).