public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu
@ 2021-06-11 4:51 qrzhang at gatech dot edu
2021-06-11 8:15 ` [Bug tree-optimization/101025] [11/12 Regression] " rguenth at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: qrzhang at gatech dot edu @ 2021-06-11 4:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
Bug ID: 101025
Summary: wrong code at -O3 on x86_64-linux-gnu
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: qrzhang at gatech dot edu
Target Milestone: ---
It appears to be a recent regression.
Bisection points to g:128f43cf679e51564202b41f23fae4146347f93d
$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210610 (experimental) [master revision
5ad76ad7f5b:c64ab1c4fe0:cce1697e6fe0134616ebc8f7040d99e66c12241a] (GCC)
$ gcc-trunk abc.c ; ./a.out
0
$ gcc-trunk -O3 abc.c ; ./a.out
4
$ cat abc.c
int a[10];
int b, d, g;
volatile char c;
short e;
volatile int f;
int main() {
for (; d <= 9; d++) {
b = e = 0;
for (; e < 10; e++)
a[e] = 4;
for (; b <= 9; b++)
if (g)
f = 0;
else
a[b] = c;
}
printf("%d\n", a[1]);
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
@ 2021-06-11 8:15 ` rguenth at gcc dot gnu.org
2021-06-11 8:27 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-11 8:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |10.3.0
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Priority|P3 |P2
Known to fail| |11.1.0, 12.0
Last reconfirmed| |2021-06-11
Target Milestone|--- |11.2
Ever confirmed|0 |1
Version|unknown |12.0
Summary|wrong code at -O3 on |[11/12 Regression] wrong
|x86_64-linux-gnu |code at -O3 on
| |x86_64-linux-gnu
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. -fno-tree-vectorize fixes it, but in the end it seems to be
store motion that moves the vector stores across the stores in the if (!g)
block. Thus -fno-tree-loop-im also fixes it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
2021-06-11 8:15 ` [Bug tree-optimization/101025] [11/12 Regression] " rguenth at gcc dot gnu.org
@ 2021-06-11 8:27 ` rguenth at gcc dot gnu.org
2021-06-11 8:59 ` marxin at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-11 8:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Shorter IL testcase:
int a[10];
int b, d, g;
volatile char c;
short e;
volatile int f;
int main()
{
for (; d <= 9; d++) {
b = e = 0;
for (; e < 4; e++)
a[e] = 4;
for (; b <= 3; b++)
if (g)
f = 0;
else
a[b] = c;
}
if (a[1] != 0)
__builtin_abort ();
return 0;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
2021-06-11 8:15 ` [Bug tree-optimization/101025] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-06-11 8:27 ` rguenth at gcc dot gnu.org
@ 2021-06-11 8:59 ` marxin at gcc dot gnu.org
2021-06-11 9:08 ` marxin at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-06-11 8:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Started in between r11-4120-g94fd05f1f76faca9 and r11-4127-g35f258f4bbba7fa0, I
can't build the commit in between.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (2 preceding siblings ...)
2021-06-11 8:59 ` marxin at gcc dot gnu.org
@ 2021-06-11 9:08 ` marxin at gcc dot gnu.org
2021-06-11 9:08 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-06-11 9:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
So started with r11-4123-g128f43cf679e51564202b41f23fae4146347f93d.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (3 preceding siblings ...)
2021-06-11 9:08 ` marxin at gcc dot gnu.org
@ 2021-06-11 9:08 ` rguenth at gcc dot gnu.org
2021-06-11 16:13 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-11 9:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is with sm_seq_valid_bb which when processing store sequences from
multiple branches of the CFG performs merging in a way that drops refs
that still need to be considered for dependence queries. Notably
/* Incrementally merge seqs into first_edge_seq. */
for (unsigned int i = 0; i < min_len; ++i)
{
/* ??? We can more intelligently merge when we face
different
order by additional sinking operations in one sequence.
For now we simply mark them as to be processed by the
not order-preserving SM code. */
if (first_edge_seq[i].first != edge_seq[i].first)
{
if (first_edge_seq[i].second == sm_ord)
bitmap_set_bit (refs_not_supported,
first_edge_seq[i].first);
if (edge_seq[i].second == sm_ord)
bitmap_set_bit (refs_not_supported, edge_seq[i].first);
first_edge_seq[i].second = sm_other;
first_edge_seq[i].from = NULL_TREE;
we re matching f ={v} 0 against a[3] = ...;, marking 'f' as not supported for
store-motion and to be dependence checked against all stores in the sequence.
But we simply forget about a[3] = ... which we'd need to insert somehow into
the sequence for dependence checking purposes similar to how we handle
/* Any excess elements become sm_other since they are now
coonditionally executed. */
if (first_edge_seq.length () > edge_seq.length ())
{
(but even that code looks suspicious). What we'd need to verify is that
we can push the ref down in 'edge_seq' (but not actually do that) and then
append it like the late loop (but we need to disambiguate against the
stores in first_edge_seq as well).
The code is quite complex and as it handles dependence queries incrementally
it's also fragile...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (4 preceding siblings ...)
2021-06-11 9:08 ` rguenth at gcc dot gnu.org
@ 2021-06-11 16:13 ` cvs-commit at gcc dot gnu.org
2021-06-11 16:13 ` [Bug tree-optimization/101025] [11 " rguenth at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-11 16:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:b8b80b8aa3d9a7abbcb59b651ea5e84c2ea12d0b
commit r12-1392-gb8b80b8aa3d9a7abbcb59b651ea5e84c2ea12d0b
Author: Richard Biener <rguenther@suse.de>
Date: Fri Jun 11 12:06:08 2021 +0200
tree-optimization/101025 - fix store-motion dependence checking
This plugs a hole in store-motion where it fails to perform dependence
checking on conditionally executed but not store-motioned refs.
2021-06-11 Richard Biener <rguenther@suse.de>
PR tree-optimization/101025
* tree-ssa-loop-im.c (sm_seq_valid_bb): Make sure to process
all refs that require dependence checking.
* gcc.dg/torture/pr101025.c: New testcase.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (5 preceding siblings ...)
2021-06-11 16:13 ` cvs-commit at gcc dot gnu.org
@ 2021-06-11 16:13 ` rguenth at gcc dot gnu.org
2021-06-11 16:26 ` qrzhang at gatech dot edu
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-11 16:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |12.0
Summary|[11/12 Regression] wrong |[11 Regression] wrong code
|code at -O3 on |at -O3 on x86_64-linux-gnu
|x86_64-linux-gnu |
Known to fail|12.0 |
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar. Keep more testcases coming ;) (I have a hunch this code
has more issues...)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (6 preceding siblings ...)
2021-06-11 16:13 ` [Bug tree-optimization/101025] [11 " rguenth at gcc dot gnu.org
@ 2021-06-11 16:26 ` qrzhang at gatech dot edu
2021-06-16 10:16 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: qrzhang at gatech dot edu @ 2021-06-11 16:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
--- Comment #8 from Qirun Zhang <qrzhang at gatech dot edu> ---
(In reply to Richard Biener from comment #7)
> Fixed on trunk sofar. Keep more testcases coming ;) (I have a hunch this
> code has more issues...)
Thanks, Richard. Will do.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (7 preceding siblings ...)
2021-06-11 16:26 ` qrzhang at gatech dot edu
@ 2021-06-16 10:16 ` rguenth at gcc dot gnu.org
2021-07-07 14:06 ` cvs-commit at gcc dot gnu.org
2021-07-07 14:08 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-16 10:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
Bug 101025 depends on bug 101088, which changed state.
Bug 101088 Summary: [12 Regression] ICE in sm_seq_valid_bb, at tree-ssa-loop-im.c:2383
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101088
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (8 preceding siblings ...)
2021-06-16 10:16 ` rguenth at gcc dot gnu.org
@ 2021-07-07 14:06 ` cvs-commit at gcc dot gnu.org
2021-07-07 14:08 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-07 14:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:8a1defec135c51531e7a0fd5085c47fca10cb147
commit r11-8695-g8a1defec135c51531e7a0fd5085c47fca10cb147
Author: Richard Biener <rguenther@suse.de>
Date: Fri Jun 11 12:06:08 2021 +0200
tree-optimization/101025 - fix store-motion dependence checking
This plugs a hole in store-motion where it fails to perform dependence
checking on conditionally executed but not store-motioned refs.
2021-06-11 Richard Biener <rguenther@suse.de>
PR tree-optimization/101025
* tree-ssa-loop-im.c (sm_seq_valid_bb): Make sure to process
all refs that require dependence checking.
* gcc.dg/torture/pr101025.c: New testcase.
(cherry picked from commit b8b80b8aa3d9a7abbcb59b651ea5e84c2ea12d0b)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/101025] [11 Regression] wrong code at -O3 on x86_64-linux-gnu
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
` (9 preceding siblings ...)
2021-07-07 14:06 ` cvs-commit at gcc dot gnu.org
@ 2021-07-07 14:08 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-07 14:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to work| |11.1.1
Resolution|--- |FIXED
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-07-07 14:08 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 4:51 [Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu qrzhang at gatech dot edu
2021-06-11 8:15 ` [Bug tree-optimization/101025] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-06-11 8:27 ` rguenth at gcc dot gnu.org
2021-06-11 8:59 ` marxin at gcc dot gnu.org
2021-06-11 9:08 ` marxin at gcc dot gnu.org
2021-06-11 9:08 ` rguenth at gcc dot gnu.org
2021-06-11 16:13 ` cvs-commit at gcc dot gnu.org
2021-06-11 16:13 ` [Bug tree-optimization/101025] [11 " rguenth at gcc dot gnu.org
2021-06-11 16:26 ` qrzhang at gatech dot edu
2021-06-16 10:16 ` rguenth at gcc dot gnu.org
2021-07-07 14:06 ` cvs-commit at gcc dot gnu.org
2021-07-07 14:08 ` rguenth 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).