public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
@ 2023-12-15 16:44 c at jia dot je
2023-12-16 17:47 ` [Bug target/113033] " xry111 at gcc dot gnu.org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: c at jia dot je @ 2023-12-15 16:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
Bug ID: 113033
Summary: GCC 14 (20231203 snapshot) ICE when building LSX
vector rotate code on LoongArch
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: c at jia dot je
Target Milestone: ---
Source code:
```
#include <lsxintrin.h>
v2u64 test(v2u64 a, int imm) {
return (a << (imm & 63)) | (a >> (64 - (imm & 63)));
}
```
Command line to reproduce:
```
gcc-14 -mlsx -c test.c
```
Error message:
```
test.c: In function ‘test’:
test.c:5:1: error: unrecognizable insn:
5 | }
| ^
(insn 16 15 17 2 (set (reg:DI 92)
(and:DI (neg:DI (reg:DI 80 [ _1 ]))
(const_int 63 [0x3f]))) "test.c":4:28 -1
(nil))
during RTL pass: vregs
test.c:5:1: internal compiler error: in extract_insn, at recog.cc:2804
0x5555591d419f internal_error(char const*, ...)
???:0
0x5555577b4d87 fancy_abort(char const*, int, char const*)
???:0
0x5555577998bb _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
???:0
0x5555577998ef _fatal_insn_not_found(rtx_def const*, char const*, int, char
const*)
???:0
0x5555580704f7 extract_insn(rtx_insn*)
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
```
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
@ 2023-12-16 17:47 ` xry111 at gcc dot gnu.org
2023-12-16 18:16 ` xry111 at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-16 17:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |chenglulu at loongson dot cn,
| |xen0n at gentoo dot org
Ever confirmed|0 |1
Last reconfirmed| |2023-12-16
Status|UNCONFIRMED |NEW
--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
2023-12-16 17:47 ` [Bug target/113033] " xry111 at gcc dot gnu.org
@ 2023-12-16 18:16 ` xry111 at gcc dot gnu.org
2023-12-16 18:32 ` xry111 at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-16 18:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
It looks like we are missing a force_reg () somewhere.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
2023-12-16 17:47 ` [Bug target/113033] " xry111 at gcc dot gnu.org
2023-12-16 18:16 ` xry111 at gcc dot gnu.org
@ 2023-12-16 18:32 ` xry111 at gcc dot gnu.org
2023-12-16 18:44 ` xry111 at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-16 18:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(define_expand "vec_init<mode><unitmode>"
[(match_operand:LSX 0 "register_operand")
(match_operand:LSX 1 "")]
"ISA_HAS_LSX"
{
loongarch_expand_vector_init (operands[0], operands[1]);
DONE;
})
We need to add a predicate for operand 1...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (2 preceding siblings ...)
2023-12-16 18:32 ` xry111 at gcc dot gnu.org
@ 2023-12-16 18:44 ` xry111 at gcc dot gnu.org
2023-12-16 20:11 ` [Bug middle-end/113033] " xry111 at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-16 18:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Strange... Most backends do not have predicate for op2 of vec_init but how do
they evade this issue?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (3 preceding siblings ...)
2023-12-16 18:44 ` xry111 at gcc dot gnu.org
@ 2023-12-16 20:11 ` xry111 at gcc dot gnu.org
2023-12-16 21:35 ` xry111 at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-16 20:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |middle-end
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
It looks like we should do:
diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index b294eabb08d..b87e09a8a65 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -2628,9 +2628,7 @@ expand_shift_1 (enum tree_code code, machine_mode mode,
rtx shifted,
(mode, GET_MODE_BITSIZE (scalar_mode) - INTVAL (op1));
else
{
- other_amount
- = simplify_gen_unary (NEG, GET_MODE (op1),
- op1, GET_MODE (op1));
+ other_amount = negate_rtx (GET_MODE (op1), op1);
HOST_WIDE_INT mask = GET_MODE_PRECISION (scalar_mode) - 1;
other_amount
= simplify_gen_binary (AND, GET_MODE (op1), other_amount,
??
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (4 preceding siblings ...)
2023-12-16 20:11 ` [Bug middle-end/113033] " xry111 at gcc dot gnu.org
@ 2023-12-16 21:35 ` xry111 at gcc dot gnu.org
2023-12-18 13:47 ` xry111 at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-16 21:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
--- Comment #6 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
There is also a missed-optimization on LoongArch. vrotlM3 should be expanded
to (rotatert X, (neg Y)) instead of two shifts and an ior.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (5 preceding siblings ...)
2023-12-16 21:35 ` xry111 at gcc dot gnu.org
@ 2023-12-18 13:47 ` xry111 at gcc dot gnu.org
2023-12-18 20:17 ` [Bug target/113033] " xry111 at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-18 13:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |https://gcc.gnu.org/piperma
| |il/gcc-patches/2023-Decembe
| |r/640871.html
Component|target |middle-end
--- Comment #7 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640871.html
I'm not convinced the ICE is a target issue. The missed-optimization is a
target issue though.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (6 preceding siblings ...)
2023-12-18 13:47 ` xry111 at gcc dot gnu.org
@ 2023-12-18 20:17 ` xry111 at gcc dot gnu.org
2023-12-18 20:34 ` xry111 at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-18 20:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |target
--- Comment #8 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #2)
> It looks like we are missing a force_reg () somewhere.
Per Jakub's review my first gut feeling seems actually correct...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (7 preceding siblings ...)
2023-12-18 20:17 ` [Bug target/113033] " xry111 at gcc dot gnu.org
@ 2023-12-18 20:34 ` xry111 at gcc dot gnu.org
2023-12-20 12:02 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-18 20:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
--- Comment #9 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
diff --git a/gcc/config/loongarch/loongarch.cc
b/gcc/config/loongarch/loongarch.cc
index 256fa7d048d..65a2915329e 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -10770,7 +10770,7 @@ loongarch_expand_vector_init_same (rtx target, rtx
vals, unsigned nvar)
gcc_unreachable ();
}
}
- temp = gen_reg_rtx (imode);
+
if (imode == GET_MODE (same))
temp2 = same;
else if (GET_MODE_SIZE (imode) >= UNITS_PER_WORD)
@@ -10795,7 +10795,8 @@ loongarch_expand_vector_init_same (rtx target, rtx
vals, unsigned nvar)
else
temp2 = lowpart_subreg (imode, same, GET_MODE (same));
}
- emit_move_insn (temp, temp2);
+
+ temp = force_reg (imode, temp2);
switch (vmode)
{
I mistakenly thought force_reg is just creating an reg and moving into it (if
the operand is not already in reg) but I was wrong.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (8 preceding siblings ...)
2023-12-18 20:34 ` xry111 at gcc dot gnu.org
@ 2023-12-20 12:02 ` cvs-commit at gcc dot gnu.org
2023-12-20 12:05 ` xry111 at gcc dot gnu.org
2023-12-27 11:05 ` xry111 at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-20 12:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:
https://gcc.gnu.org/g:c7eefea622e70bd63b0e00e896f67cf9ee9916bc
commit r14-6746-gc7eefea622e70bd63b0e00e896f67cf9ee9916bc
Author: Xi Ruoyao <xry111@xry111.site>
Date: Tue Dec 19 04:48:03 2023 +0800
LoongArch: Use force_reg instead of gen_reg_rtx + emit_move_insn in
vec_init expander [PR113033]
Jakub says:
Then that seems like a bug in the loongarch vec_init pattern(s).
Those really don't have a predicate in any of the backends on the
input operand, so they need to force_reg it if it is something it
can't handle. I've looked e.g. at i386 vec_init and that is exactly
what it does, see the various tests + force_reg calls in
ix86_expand_vector_init*.
So replace gen_reg_rtx + emit_move_insn with force_reg to fix PR 113033.
gcc/ChangeLog:
PR target/113033
* config/loongarch/loongarch.cc
(loongarch_expand_vector_init_same): Replace gen_reg_rtx +
emit_move_insn with force_reg.
(loongarch_expand_vector_init): Likewise.
gcc/testsuite/ChangeLog:
PR target/113033
* gcc.target/loongarch/pr113033.c: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (9 preceding siblings ...)
2023-12-20 12:02 ` cvs-commit at gcc dot gnu.org
@ 2023-12-20 12:05 ` xry111 at gcc dot gnu.org
2023-12-27 11:05 ` xry111 at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-20 12:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #11 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
ICE fixed. Missed-optimization is
https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640872.html.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/113033] GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
` (10 preceding siblings ...)
2023-12-20 12:05 ` xry111 at gcc dot gnu.org
@ 2023-12-27 11:05 ` xry111 at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-27 11:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
--- Comment #12 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Missed-optimization fixed at r14-6851.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-12-27 11:05 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-15 16:44 [Bug target/113033] New: GCC 14 (20231203 snapshot) ICE when building LSX vector rotate code on LoongArch c at jia dot je
2023-12-16 17:47 ` [Bug target/113033] " xry111 at gcc dot gnu.org
2023-12-16 18:16 ` xry111 at gcc dot gnu.org
2023-12-16 18:32 ` xry111 at gcc dot gnu.org
2023-12-16 18:44 ` xry111 at gcc dot gnu.org
2023-12-16 20:11 ` [Bug middle-end/113033] " xry111 at gcc dot gnu.org
2023-12-16 21:35 ` xry111 at gcc dot gnu.org
2023-12-18 13:47 ` xry111 at gcc dot gnu.org
2023-12-18 20:17 ` [Bug target/113033] " xry111 at gcc dot gnu.org
2023-12-18 20:34 ` xry111 at gcc dot gnu.org
2023-12-20 12:02 ` cvs-commit at gcc dot gnu.org
2023-12-20 12:05 ` xry111 at gcc dot gnu.org
2023-12-27 11:05 ` xry111 at gcc dot gnu.org
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).