public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
@ 2022-02-14 16:40 theodort at inf dot ethz.ch
2022-02-14 16:47 ` [Bug tree-optimization/104530] " jakub at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: theodort at inf dot ethz.ch @ 2022-02-14 16:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
Bug ID: 104530
Summary: [12 Regression] Dead Code Elimination Regression at
-O3 (trunk vs. 11.2.0)
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: theodort at inf dot ethz.ch
Target Milestone: ---
Dead Code Elimination Regression at -O3 (trunk vs.
a7fede6704dd207fb32b97bc30f945acc7b953c5) 138751
---------------
cat case.c #138751
void foo(void);
static int a, *b = &a, c, d = 1;
int main() {
c = 0 == b;
a = *b;
if (c % d)
for (; d; --d)
foo();
b = 0;
}
gcc-58aeb75d4097010ad9bb72b964265b18ab284f93 (trunk) -O3 can not eliminate foo
but gcc-11.2.0 -O3 can.
gcc-58aeb75d4097010ad9bb72b964265b18ab284f93 (trunk) -O3 -S -o /dev/stdout
case.c
--------- OUTPUT ---------
main:
.LFB0:
.cfi_startproc
movq b(%rip), %rax
testq %rax, %rax
movl (%rax), %edx
sete %al
movzbl %al, %eax
movl %edx, a(%rip)
cltd
idivl d(%rip)
testl %edx, %edx
je .L9
pushq %rax
.cfi_def_cfa_offset 16
.p2align 4,,10
.p2align 3
.L3:
call foo
subl $1, d(%rip)
jne .L3
xorl %ecx, %ecx
xorl %eax, %eax
movq %rcx, b(%rip)
popq %rsi
.cfi_def_cfa_offset 8
ret
.L9:
xorl %edx, %edx
xorl %eax, %eax
movq %rdx, b(%rip)
ret
---------- END OUTPUT ---------
gcc-11.2.0 -O3 -S -o /dev/stdout case.c
--------- OUTPUT ---------
main:
.LFB0:
.cfi_startproc
movq b(%rip), %rax
movq $0, b(%rip)
movl (%rax), %eax
movl %eax, a(%rip)
xorl %eax, %eax
ret
---------- END OUTPUT ---------
Bisects to:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c6bb1db76b3ac127aff7dacf391fc1798a94bb7d
----- Build information -----
----- 58aeb75d4097010ad9bb72b964265b18ab284f93 (trunk)
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
--prefix=/zdata/compiler_cache/gcc-58aeb75d4097010ad9bb72b964265b18ab284f93
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220213 (experimental) (GCC)
----- releases/gcc-11.2.0
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 (GCC)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/104530] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
@ 2022-02-14 16:47 ` jakub at gcc dot gnu.org
2022-02-15 23:14 ` amacleod at redhat dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-02-14 16:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
CC| |jakub at gcc dot gnu.org
Priority|P3 |P1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r12-7128-gc6bb1db76b3ac127aff7dacf391fc1798a94bb7d
The comparison is done before dereferencing pointer, but unlike the PR104288
case there is no call that could fail to return in between.
I think PR104288 has been fixed on the 11 branch too, so the question is if
this still works there.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/104530] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
2022-02-14 16:47 ` [Bug tree-optimization/104530] " jakub at gcc dot gnu.org
@ 2022-02-15 23:14 ` amacleod at redhat dot com
2022-02-21 13:10 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2022-02-15 23:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
--- Comment #2 from Andrew Macleod <amacleod at redhat dot com> ---
mmm. tricky.
Imports: b.0_1 d.3_7
Exports: b.0_1 _2 _3 d.3_7 _8
_2 : b.0_1(I)
_3 : b.0_1(I) _2
_8 : b.0_1(I) _2 _3 d.3_7(I)
<bb 2> :
b.0_1 = b;
_2 = b.0_1 == 0B;
_3 = (int) _2;
c = _3;
_5 = *b.0_1; <<-- from this point b.0_1 is [+1, +INF]
a = _5;
d.3_7 = d;
_8 = _3 % d.3_7;
if (_8 != 0)
goto <bb 6>; [INV]
else
goto <bb 5>; [INV]
This is a bit at conflict with the "lets be safe" approach without pre-scanning
the block for lack of throwing stmts. Although that's really just a half
measure since you can construct more complicated blocks with a mix.
Im experimenting with marking values as stale for all exports of the block
which are dependant on the value we set to non null. ie, _2, _3 and _8
Then when we ask for a range of that name AFTER the de-reference, it will
recompute it. The use of _3 in computing _8 is then "stale", and will be
re-evaluated.
Simple in concept, but I'm encountering an interaction with how we currently
set the global values for the end of the pass, and although I can recompute _2
fine, it is also setting the global value of _2 to [0,0], which is not what we
want. Works for this case, but returns us to the same situation we had before
if there is a call in the block.
Im continuing to look at it. Easy fix in the next release since we are going
to change the way we export globals outside the pass... but we shall see about
this release whether I can keep it contained.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/104530] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
2022-02-14 16:47 ` [Bug tree-optimization/104530] " jakub at gcc dot gnu.org
2022-02-15 23:14 ` amacleod at redhat dot com
@ 2022-02-21 13:10 ` jakub at gcc dot gnu.org
2022-04-19 15:36 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-02-21 13:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
What could be done in passes like evrp or vrp* but not in unrelated other
passes that use the range infrastructure would be to set uids on stmts
depending on presence of calls that might not always return in the middle of
basic blocks (and perhaps other stmts, wonder about e.g. inline asm),
and optimize whenever the comparison and dereference have the same uid (aka
there is nothing in between that would make the optimization problematic).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/104530] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
` (2 preceding siblings ...)
2022-02-21 13:10 ` jakub at gcc dot gnu.org
@ 2022-04-19 15:36 ` rguenth at gcc dot gnu.org
2022-05-06 8:32 ` [Bug tree-optimization/104530] [12/13 " jakub at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-19 15:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P1 |P2
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Downgrading, lets defer to GCC 13 (we can still backport if the solution is
suitable).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/104530] [12/13 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
` (3 preceding siblings ...)
2022-04-19 15:36 ` rguenth at gcc dot gnu.org
@ 2022-05-06 8:32 ` jakub at gcc dot gnu.org
2022-11-08 0:22 ` cvs-commit at gcc dot gnu.org
2022-11-08 0:23 ` amacleod at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-06 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|12.0 |12.2
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 12.1 is being released, retargeting bugs to GCC 12.2.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/104530] [12/13 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
` (4 preceding siblings ...)
2022-05-06 8:32 ` [Bug tree-optimization/104530] [12/13 " jakub at gcc dot gnu.org
@ 2022-11-08 0:22 ` cvs-commit at gcc dot gnu.org
2022-11-08 0:23 ` amacleod at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-08 0:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Macleod <amacleod@gcc.gnu.org>:
https://gcc.gnu.org/g:c838119946c9f75f1e42f4320275355822cc86fc
commit r13-3765-gc838119946c9f75f1e42f4320275355822cc86fc
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Mon Nov 7 15:07:35 2022 -0500
Add transitive inferred range processing.
Rewalk statements at the end of a block to see if any inferred ranges
affect earlier calculations and register those as inferred ranges.
gcc/
PR tree-optimization/104530
* gimple-range-cache.cc (ranger_cache::register_inferred_value):
New. Split from:
(ranger_cache::apply_inferred_ranges): Move setting cache to
separate function.
* gimple-range-cache.h (register_inferred_value): New prototype.
* gimple-range-infer.cc (infer_range_manager::has_range_p): New.
* gimple-range-infer.h (has_range_p): New prototype.
* gimple-range.cc (register_transitive_inferred_ranges): New.
* gimple-range.h (register_transitive_inferred_ranges): New proto.
* tree-vrp.cc (rvrp_folder::fold_stmt): Check for transitive
inferred
ranges at the end of the block before folding final stmt.
gcc/testsuite/
* gcc.dg/pr104530.c: New.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/104530] [12/13 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0)
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
` (5 preceding siblings ...)
2022-11-08 0:22 ` cvs-commit at gcc dot gnu.org
@ 2022-11-08 0:23 ` amacleod at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2022-11-08 0:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104530
Andrew Macleod <amacleod at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #8 from Andrew Macleod <amacleod at redhat dot com> ---
fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-11-08 0:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 16:40 [Bug tree-optimization/104530] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 11.2.0) theodort at inf dot ethz.ch
2022-02-14 16:47 ` [Bug tree-optimization/104530] " jakub at gcc dot gnu.org
2022-02-15 23:14 ` amacleod at redhat dot com
2022-02-21 13:10 ` jakub at gcc dot gnu.org
2022-04-19 15:36 ` rguenth at gcc dot gnu.org
2022-05-06 8:32 ` [Bug tree-optimization/104530] [12/13 " jakub at gcc dot gnu.org
2022-11-08 0:22 ` cvs-commit at gcc dot gnu.org
2022-11-08 0:23 ` amacleod at redhat dot com
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).