public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
@ 2021-11-15 18:21 theodort at inf dot ethz.ch
2021-11-15 18:35 ` [Bug tree-optimization/103257] " aldyh at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: theodort at inf dot ethz.ch @ 2021-11-15 18:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Bug ID: 103257
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: ---
cat case.c
void foo(void);
unsigned b, c;
static short a(short e, short f) { return e * f; }
int main() {
if (a(1 ^ ((0, 0) ^ 1 && b) <= b, c))
foo();
c = 0;
}
11.2.0 at -O3 can eliminate the call to foo but trunk at -O3 cannot:
gcc11 case.c -S -O3 -o /dev/stdout
main:
.LFB1:
.cfi_startproc
movl b(%rip), %eax
xorl %edx, %edx
testl %eax, %eax
setne %dl
cmpl %edx, %eax
movl $0, %eax
cmovb c(%rip), %ax
testw %ax, %ax
jne .L11
movl $0, c(%rip)
xorl %eax, %eax
ret
.L11:
pushq %rax
.cfi_def_cfa_offset 16
call foo
xorl %edx, %edx
xorl %eax, %eax
movl %edx, c(%rip)
popq %rcx
.cfi_def_cfa_offset 8
ret
.cfi_endproc
gcc-trunk -v
Target: x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211115 (experimental) (GCC)
It started with
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0288527f47cec6698b31ccb3210816415506009e
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
@ 2021-11-15 18:35 ` aldyh at gcc dot gnu.org
2021-11-15 21:38 ` amacleod at redhat dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: aldyh at gcc dot gnu.org @ 2021-11-15 18:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amacleod at redhat dot com
--- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Looks like something either VRP or the threader could get.
By vrp2 we have:
=========== BB 2 ============
Imports: c.0_1
Exports: c.0_1 f.6_9 _10
f.6_9 : c.0_1(I)
_10 : c.0_1(I) f.6_9
<bb 2> [local count: 1073741824]:
c.0_1 = c;
b.2_2 = b;
_11 = b.2_2 != 0;
iftmp.3_3 = (unsigned int) _11;
f.6_9 = (unsigned short) c.0_1;
_10 = b.2_2 < iftmp.3_3 ? f.6_9 : 0;
if (_10 != 0)
goto <bb 3>; [33.00%]
else
goto <bb 4>; [67.00%]
iftmp.3_3 : unsigned int [0, 1]
2->3 (T) _10 : unsigned short [1, +INF]
2->4 (F) _10 : unsigned short [0, 0]
=========== BB 3 ============
<bb 3> [local count: 354334800]:
foo ();
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-11-15 18:35 ` [Bug tree-optimization/103257] " aldyh at gcc dot gnu.org
@ 2021-11-15 21:38 ` amacleod at redhat dot com
2021-11-16 0:40 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: amacleod at redhat dot com @ 2021-11-15 21:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
--- Comment #2 from Andrew Macleod <amacleod at redhat dot com> ---
At issue is GORI does not yet process COND_EXPRS, so we cannot do any
evaluations to refine ranges on outgoing edges. It is on the list :-)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-11-15 18:35 ` [Bug tree-optimization/103257] " aldyh at gcc dot gnu.org
2021-11-15 21:38 ` amacleod at redhat dot com
@ 2021-11-16 0:40 ` pinskia at gcc dot gnu.org
2021-11-16 0:44 ` [Bug tree-optimization/103257] [9/10/11/12 " pinskia at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 0:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
Keywords| |missed-optimization
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (2 preceding siblings ...)
2021-11-16 0:40 ` pinskia at gcc dot gnu.org
@ 2021-11-16 0:44 ` pinskia at gcc dot gnu.org
2021-11-16 0:48 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 0:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-11-16
Known to work| |5.1.0, 7.2.0
Known to fail| |10.1.0, 8.1.0
Target Milestone|12.0 |9.5
Summary|[12 Regression] Dead Code |[9/10/11/12 Regression]
|Elimination Regression at |Dead Code Elimination
|-O3 (trunk vs 11.2.0) |Regression at -O3 (trunk vs
| |11.2.0)
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note this used to be optimized at the gimple level for GCC 7 and before. So
marking it as a regression from that point forward.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (3 preceding siblings ...)
2021-11-16 0:44 ` [Bug tree-optimization/103257] [9/10/11/12 " pinskia at gcc dot gnu.org
@ 2021-11-16 0:48 ` pinskia at gcc dot gnu.org
2021-11-16 1:01 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 0:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu.org
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
r8-2090 caused the issue to show up. Maybe this pattern should be disabled
until canonicalize_math_p () is false.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (4 preceding siblings ...)
2021-11-16 0:48 ` pinskia at gcc dot gnu.org
@ 2021-11-16 1:01 ` pinskia at gcc dot gnu.org
2021-11-16 4:52 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 1:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> r8-2090 caused the issue to show up. Maybe this pattern should be disabled
> until canonicalize_math_p () is false.
I am going to implement that.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (5 preceding siblings ...)
2021-11-16 1:01 ` pinskia at gcc dot gnu.org
@ 2021-11-16 4:52 ` pinskia at gcc dot gnu.org
2021-11-16 9:35 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 4:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 51804
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51804&action=edit
untested Patch
This is the patch which I am testing. I checked all of tree-ssa.exp and there
are no failures. I still need to do a full bootstrap/test.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (6 preceding siblings ...)
2021-11-16 4:52 ` pinskia at gcc dot gnu.org
@ 2021-11-16 9:35 ` rguenth at gcc dot gnu.org
2021-11-17 8:02 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-16 9:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Good idea.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (7 preceding siblings ...)
2021-11-16 9:35 ` rguenth at gcc dot gnu.org
@ 2021-11-17 8:02 ` pinskia at gcc dot gnu.org
2021-11-19 6:41 ` cvs-commit at gcc dot gnu.org
2021-11-19 6:43 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17 8:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
URL| |https://gcc.gnu.org/piperma
| |il/gcc-patches/2021-Novembe
| |r/584677.html
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch submitted:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584677.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (8 preceding siblings ...)
2021-11-17 8:02 ` pinskia at gcc dot gnu.org
@ 2021-11-19 6:41 ` cvs-commit at gcc dot gnu.org
2021-11-19 6:43 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-19 6:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:527e54a431473cc497204226a21f2831d2375e66
commit r12-5392-g527e54a431473cc497204226a21f2831d2375e66
Author: Andrew Pinski <apinski@marvell.com>
Date: Tue Nov 16 04:46:21 2021 +0000
Fix tree-optimization/103257: Missed jump threading due too early
conversion of bool*A into bool?A:0
So like many optimizations on the gimple level, sometimes it makes sense to
do the
optimization early or later. In this case, creating a cond expression early
causes
other optimizations to be missed. So just disable it until
canonicalize_math_p ()
is false.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/103257
gcc/ChangeLog:
* match.pd
((m1 >/</>=/<= m2) * d -> (m1 >/</>=/<= m2) ? d : 0):
Disable until !canonicalize_math_p ().
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp116.c: Check optimized instead of vrp1.
* gcc.dg/tree-ssa/pr103257-1.c: New test.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/103257] [9/10/11/12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
` (9 preceding siblings ...)
2021-11-19 6:41 ` cvs-commit at gcc dot gnu.org
@ 2021-11-19 6:43 ` pinskia at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-19 6:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|9.5 |12.0
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed on the trunk, not going to backport for GCC 9 or 10 since it is a small
missed optimization, not found until now.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-11-19 6:43 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 18:21 [Bug tree-optimization/103257] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-11-15 18:35 ` [Bug tree-optimization/103257] " aldyh at gcc dot gnu.org
2021-11-15 21:38 ` amacleod at redhat dot com
2021-11-16 0:40 ` pinskia at gcc dot gnu.org
2021-11-16 0:44 ` [Bug tree-optimization/103257] [9/10/11/12 " pinskia at gcc dot gnu.org
2021-11-16 0:48 ` pinskia at gcc dot gnu.org
2021-11-16 1:01 ` pinskia at gcc dot gnu.org
2021-11-16 4:52 ` pinskia at gcc dot gnu.org
2021-11-16 9:35 ` rguenth at gcc dot gnu.org
2021-11-17 8:02 ` pinskia at gcc dot gnu.org
2021-11-19 6:41 ` cvs-commit at gcc dot gnu.org
2021-11-19 6:43 ` pinskia 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).