* [Bug rtl-optimization/112380] [14 regression] ICE when building mesa
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
@ 2023-11-04 14:32 ` sjames at gcc dot gnu.org
2023-11-04 15:45 ` sjames at gcc dot gnu.org
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-04 14:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
I'll try reduce it now.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building mesa
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
2023-11-04 14:32 ` [Bug rtl-optimization/112380] " sjames at gcc dot gnu.org
@ 2023-11-04 15:45 ` sjames at gcc dot gnu.org
2023-11-04 15:57 ` sjames at gcc dot gnu.org
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-04 15:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
reduced:
```
enum { TGSI_FILE_NULL };
struct ureg_src {
unsigned File : 4;
unsigned : 2;
unsigned : 2;
unsigned : 2;
unsigned : 1;
unsigned IndirectFile : 4;
unsigned IndirectSwizzle : 2;
int : 16;
int : 6;
int : 16;
int : 16;
unsigned : 10;
} __trans_tmp_1;
int ureg_src_indirect_addr_1, ntt_emit_texture_instr_sampler_handle_src;
void ureg_scalar(struct ureg_src);
void ntt_emit_texture_instr() {
struct ureg_src sampler;
if (ntt_emit_texture_instr_sampler_handle_src)
sampler = __trans_tmp_1;
struct ureg_src reg = sampler;
reg.File != TGSI_FILE_NULL;
reg.IndirectFile = reg.IndirectSwizzle = ureg_src_indirect_addr_1;
sampler = reg;
ureg_scalar(reg);
}
```
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building mesa
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
2023-11-04 14:32 ` [Bug rtl-optimization/112380] " sjames at gcc dot gnu.org
2023-11-04 15:45 ` sjames at gcc dot gnu.org
@ 2023-11-04 15:57 ` sjames at gcc dot gnu.org
2023-11-04 17:01 ` pinskia at gcc dot gnu.org
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-04 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #3 from Sam James <sjames at gcc dot gnu.org> ---
might not be a 14 regression, I need to build older gccs with more checking
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building mesa
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (2 preceding siblings ...)
2023-11-04 15:57 ` sjames at gcc dot gnu.org
@ 2023-11-04 17:01 ` pinskia at gcc dot gnu.org
2023-11-04 17:47 ` [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) sjames at gcc dot gnu.org
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-04 17:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg)
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (3 preceding siblings ...)
2023-11-04 17:01 ` pinskia at gcc dot gnu.org
@ 2023-11-04 17:47 ` sjames at gcc dot gnu.org
2023-11-04 18:02 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-04 17:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Sam James from comment #3)
> might not be a 14 regression, I need to build older gccs with more checking
ok, it is a 14 regression
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg)
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (4 preceding siblings ...)
2023-11-04 17:47 ` [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) sjames at gcc dot gnu.org
@ 2023-11-04 18:02 ` pinskia at gcc dot gnu.org
2023-11-04 19:16 ` [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-4612-g6decda1a35be57 sjames at gcc dot gnu.org
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-04 18:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
Trying 25, 31, 32 -> 34:
25: strict_low_part(r114:TI#0)=r102:QI
REG_DEAD r102:QI
31: {r131:SI=r130:SI&0x1f800;clobber flags:CC;}
REG_DEAD r130:SI
REG_UNUSED flags:CC
32: {r132:SI=r114:TI#0&0xfffffffffffe07ff;clobber flags:CC;}
REG_UNUSED flags:CC
34: {r134:DI=zero_extend(r131:SI|r132:SI);clobber flags:CC;}
REG_UNUSED flags:CC
REG_DEAD r131:SI
REG_DEAD r132:SI
```
Then crash.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-4612-g6decda1a35be57
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (5 preceding siblings ...)
2023-11-04 18:02 ` pinskia at gcc dot gnu.org
@ 2023-11-04 19:16 ` sjames at gcc dot gnu.org
2023-11-04 19:32 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-04 19:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
Summary|[14 regression] ICE when |[14 regression] ICE when
|building Mesa (in combine, |building Mesa (in combine,
|internal compiler error: in |internal compiler error: in
|simplify_subreg) |simplify_subreg) since
| |r14-4612-g6decda1a35be57
--- Comment #6 from Sam James <sjames at gcc dot gnu.org> ---
bisect says:
commit r14-4612-g6decda1a35be57
Author: Richard Biener <rguenther@suse.de>
Date: Thu Oct 12 11:34:57 2023 +0200
tree-optimization/111779 - Handle some BIT_FIELD_REFs in SRA
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-4612-g6decda1a35be57
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (6 preceding siblings ...)
2023-11-04 19:16 ` [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-4612-g6decda1a35be57 sjames at gcc dot gnu.org
@ 2023-11-04 19:32 ` pinskia at gcc dot gnu.org
2023-11-04 19:40 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-04 19:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Sam James from comment #6)
> bisect says:
>
> commit r14-4612-g6decda1a35be57
> Author: Richard Biener <rguenther@suse.de>
> Date: Thu Oct 12 11:34:57 2023 +0200
>
> tree-optimization/111779 - Handle some BIT_FIELD_REFs in SRA
That almost definitely just exposed the issue. Let me see if I can get a
testcase that fails without depending on that.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-4612-g6decda1a35be57
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (7 preceding siblings ...)
2023-11-04 19:32 ` pinskia at gcc dot gnu.org
@ 2023-11-04 19:40 ` pinskia at gcc dot gnu.org
2023-11-05 9:19 ` sjames at gcc dot gnu.org
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-04 19:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-11-04
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #7)
> That almost definitely just exposed the issue. Let me see if I can get a
> testcase that fails without depending on that.
New testcase which seems to have the same IR going into expand for GCC 13.2.0
and the trunk:
```
struct ureg_src {
unsigned File : 4;
unsigned : 2;
unsigned : 2;
unsigned : 2;
unsigned : 1;
unsigned IndirectFile : 4;
unsigned IndirectSwizzle : 2;
int : 16;
int : 6;
int : 16;
int : 16;
unsigned : 10;
} __trans_tmp_1;
int hh, nn;
void ureg_scalar(struct ureg_src);
void ntt_emit_texture_instr() {
struct ureg_src sampler;
unsigned char *t = ((char*)&sampler);
unsigned char t1;
unsigned t2, t3;
if (nn) {
sampler = __trans_tmp_1;
t1 = *t;
t2 = sampler.IndirectFile;
t3 = sampler.IndirectSwizzle;
}
struct ureg_src reg = sampler;
*t = t1;
ureg_scalar(reg);
}
```
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-4612-g6decda1a35be57
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (8 preceding siblings ...)
2023-11-04 19:40 ` pinskia at gcc dot gnu.org
@ 2023-11-05 9:19 ` sjames at gcc dot gnu.org
2023-11-05 19:15 ` [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-2526-g8911879415d6c2 roger at nextmovesoftware dot com
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-05 9:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |roger at nextmovesoftware dot com
--- Comment #9 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #8)
> (In reply to Andrew Pinski from comment #7)
> > That almost definitely just exposed the issue. Let me see if I can get a
> > testcase that fails without depending on that.
>
> New testcase which seems to have the same IR going into expand for GCC
> 13.2.0 and the trunk:
> [...]
This one seems to have started with:
commit r14-2526-g8911879415d6c2
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Fri Jul 14 18:10:05 2023 +0100
i386: Improved insv of DImode/DFmode {high,low}parts into TImode.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-2526-g8911879415d6c2
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (9 preceding siblings ...)
2023-11-05 9:19 ` sjames at gcc dot gnu.org
@ 2023-11-05 19:15 ` roger at nextmovesoftware dot com
2023-11-12 22:42 ` sjames at gcc dot gnu.org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-11-05 19:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |roger at nextmovesoftware dot com
Status|NEW |ASSIGNED
--- Comment #10 from Roger Sayle <roger at nextmovesoftware dot com> ---
combine.cc's expand_field_assignment needs to defend against gen_lowpart (which
is gen_lowpart_for_combine) returning a CLOBBER. Otherwise, we end up calling
simplify_set on:
(set (reg:DI 134)
(and:DI (subreg:DI (ior:SI (ior:SI (and:SI (subreg:SI (reg/v:TI 114 [
sampler ]) 0)
(const_int -129280 [0xfffffffffffe0700]))
(and:SI (clobber:TI (const_int 0 [0]))
(const_int -129025 [0xfffffffffffe07ff])))
(and:SI (reg:SI 130)
(const_int 129024 [0x1f800]))) 0)
(const_int 4294967295 [0xffffffff])))
where if you look closely the "(clobber:TI (const_int 0))" causes no end of fun
in simplify_rtx; it's not surprising that an assert is eventually triggered in
simplify_subreg.
I'm testing a patch.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-2526-g8911879415d6c2
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (10 preceding siblings ...)
2023-11-05 19:15 ` [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-2526-g8911879415d6c2 roger at nextmovesoftware dot com
@ 2023-11-12 22:42 ` sjames at gcc dot gnu.org
2023-11-12 23:26 ` roger at nextmovesoftware dot com
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-12 22:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #11 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Roger Sayle from comment #10)
>
> I'm testing a patch.
Did you get anywhere in the end?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-2526-g8911879415d6c2
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (11 preceding siblings ...)
2023-11-12 22:42 ` sjames at gcc dot gnu.org
@ 2023-11-12 23:26 ` roger at nextmovesoftware dot com
2023-12-11 17:33 ` cvs-commit at gcc dot gnu.org
2023-12-16 9:25 ` roger at nextmovesoftware dot com
14 siblings, 0 replies; 16+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-11-12 23:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #12 from Roger Sayle <roger at nextmovesoftware dot com> ---
Patch proposed (actually two alternatives proposed) at
https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636203.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-2526-g8911879415d6c2
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (12 preceding siblings ...)
2023-11-12 23:26 ` roger at nextmovesoftware dot com
@ 2023-12-11 17:33 ` cvs-commit at gcc dot gnu.org
2023-12-16 9:25 ` roger at nextmovesoftware dot com
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-11 17:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:
https://gcc.gnu.org/g:624e274ca3a4405a55662fa72d1163120df0e03d
commit r14-6424-g624e274ca3a4405a55662fa72d1163120df0e03d
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Mon Dec 11 17:30:20 2023 +0000
PR rtl-optimization/112380: Defend against CLOBBERs in combine.cc
This patch addresses PR rtl-optimization/112380, an ICE-on-valid regression
where a (clobber (const_int 0)) encounters a sanity checking gcc_assert
(at line 7554) in simplify-rtx.cc. These CLOBBERs are used internally
by GCC's combine pass much like error_mark_node is used by various
language front-ends.
The solutions are either to handle/accept these CLOBBERs through-out
(or in more places in) the middle-end's RTL optimizers, including functions
in simplify-rtx.cc that are used by passes other than combine, and/or
attempt to prevent these CLOBBERs escaping from try_combine into the
RTX/RTL stream. The benefit of the second approach is that it actually
allows for better optimization: when try_combine fails to simplify an
expression instead of substituting a CLOBBER to avoid the instruction
pattern being recognized, noticing the CLOBBER often allows combine
to attempt alternate simplifications/transformations looking for those
that can be recognized.
This first alternative is the minimal fix to address the CLOBBER
encountered in the bugzilla PR.
2023-12-11 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR rtl-optimization/112380
* combine.cc (expand_field_assignment): Check if gen_lowpart
returned a CLOBBER, and avoid calling gen_simplify_binary with
it if so.
gcc/testsuite/ChangeLog
PR rtl-optimization/112380
* gcc.dg/pr112380.c: New test case.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug rtl-optimization/112380] [14 regression] ICE when building Mesa (in combine, internal compiler error: in simplify_subreg) since r14-2526-g8911879415d6c2
2023-11-04 14:32 [Bug rtl-optimization/112380] New: [14 regression] ICE when building mesa sjames at gcc dot gnu.org
` (13 preceding siblings ...)
2023-12-11 17:33 ` cvs-commit at gcc dot gnu.org
@ 2023-12-16 9:25 ` roger at nextmovesoftware dot com
14 siblings, 0 replies; 16+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-12-16 9:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112380
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #14 from Roger Sayle <roger at nextmovesoftware dot com> ---
This should now be fixed on mainline, but similar issues may still be latent in
combine (see the longer alternative in comment #12).
^ permalink raw reply [flat|nested] 16+ messages in thread