[Bug tree-optimization/104263] [10/11/12 Regression] '-fcompare-debug' failure (length) w/ -O2 -fnon-call-exceptions -fno-inline-small-functions since r10-3575-g629387a6586a7531

2022-01-28 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104263

--- Comment #10 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:a591c71b41e18e4ff86852a974592af4962aef57

commit r12-6923-ga591c71b41e18e4ff86852a974592af4962aef57
Author: Jakub Jelinek 
Date:   Fri Jan 28 19:02:26 2022 +0100

store-merging: Fix up a -fcompare-debug bug in get_status_for_store_merging
[PR104263]

As mentioned in the PRthe following testcase fails, because the last
stmt of a bb with -g is a debug stmt and get_status_for_store_merging
uses gimple_seq_last_stmt (bb_seq (bb)) when testing if it is valid
for store merging.  The debug stmt isn't valid, while a stmt at that
position with -g0 is valid and so the divergence.

As we walk the whole bb already, this patch just remembers the last
non-debug stmt, so that we don't need to skip backwards debug stmts at the
end of the bb to find last real stmt.

2022-01-28  Jakub Jelinek  

PR tree-optimization/104263
* gimple-ssa-store-merging.cc (get_status_for_store_merging): For
cfun->can_throw_non_call_exceptions && cfun->eh test whether
last non-debug stmt in the bb is store_valid_for_store_merging_p
rather than last stmt.

* gcc.dg/pr104263.c: New test.

[Bug tree-optimization/104263] [10/11/12 Regression] '-fcompare-debug' failure (length) w/ -O2 -fnon-call-exceptions -fno-inline-small-functions since r10-3575-g629387a6586a7531

2022-01-28 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104263

--- Comment #9 from CVS Commits  ---
The master branch has been updated by Richard Biener :

https://gcc.gnu.org/g:5b6f04276e3d1f20817ed37b2e26e43bd12cc0d2

commit r12-6917-g5b6f04276e3d1f20817ed37b2e26e43bd12cc0d2
Author: Richard Biener 
Date:   Fri Jan 28 10:55:29 2022 +0100

tree-optimization/104263 - avoid retaining abnormal edges for non-call/goto
stmts

This removes a premature optimization from
gimple_purge_dead_abnormal_call_edges which, after eliding the
last setjmp (or computed goto) statement from a function and
thus clearing cfun->calls_setjmp, leaves us with the abnormal
edges from other calls that are elided for example via inlining
or DCE.  That's a CFG / IL combination that should be impossible
(not addressing the fact that with cfun->calls_setjmp and
cfun->has_nonlocal_label cleared we should not have any abnormal
edge at all).

For the testcase in the PR this means that IPA inlining will
remove the abormal edges from the block after inlining the call
the edge was coming from.

2022-01-28  Richard Biener  

PR tree-optimization/104263
* tree-cfg.cc (gimple_purge_dead_abnormal_call_edges):
Purge edges also when !cfun->has_nonlocal_label
and !cfun->calls_setjmp.

* gcc.dg/tree-ssa/inline-13.c: New testcase.

[Bug tree-optimization/104263] [10/11/12 Regression] '-fcompare-debug' failure (length) w/ -O2 -fnon-call-exceptions -fno-inline-small-functions since r10-3575-g629387a6586a7531

2022-01-28 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104263

--- Comment #8 from Eric Botcazou  ---
> Untested fix for the store-merging bug.

FWIW it looks good to me, thanks!

[Bug tree-optimization/104263] [10/11/12 Regression] '-fcompare-debug' failure (length) w/ -O2 -fnon-call-exceptions -fno-inline-small-functions since r10-3575-g629387a6586a7531

2022-01-28 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104263

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek  ---
Created attachment 52309
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52309=edit
gcc12-pr104263.patch

Untested fix for the store-merging bug.

[Bug tree-optimization/104263] [10/11/12 Regression] '-fcompare-debug' failure (length) w/ -O2 -fnon-call-exceptions -fno-inline-small-functions since r10-3575-g629387a6586a7531

2022-01-28 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104263

--- Comment #6 from Richard Biener  ---
I'm testing a patch to gimple_purge_dead_abnormal_call_edges, leaving the
store-merging issue to Jakub.

[Bug tree-optimization/104263] [10/11/12 Regression] '-fcompare-debug' failure (length) w/ -O2 -fnon-call-exceptions -fno-inline-small-functions since r10-3575-g629387a6586a7531

2022-01-28 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104263

--- Comment #5 from Richard Biener  ---
OK, so with the abnormal edges the issue is that DCE1 removes the recursive
call to foo () (because the function is "wrongly" pure) which causes us to
clear
cfun->calls_setjmp but then any further gimple_purge_dead_abnormal_call_edges
will simply do nothing (as premature optimization one could guess).  So the
bug would be that we fail to wipe all abnormal edges when a function no
longer calls setjmp or has a nonlocal label.

The easiest fix is to remove the premature optimization in
gimple_purge_dead_abnormal_call_edges.  That leaves the abnormal edges from
bar() even after DCE removes the recursive call to foo() (still a missed
optimization) but it at least will not leave us with stray abnormal edges
from non-call / non-computed goto stmts in the IL.

It also resolves the compare-debug failure for this testcase (but maybe there's
a latent issue in store-merging still).

[Bug tree-optimization/104263] [10/11/12 Regression] '-fcompare-debug' failure (length) w/ -O2 -fnon-call-exceptions -fno-inline-small-functions since r10-3575-g629387a6586a7531

2022-01-28 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104263

Martin Liška  changed:

   What|Removed |Added

Summary|[10/11/12 Regression]   |[10/11/12 Regression]
   |'-fcompare-debug' failure   |'-fcompare-debug' failure
   |(length) w/ -O2 |(length) w/ -O2
   |-fnon-call-exceptions   |-fnon-call-exceptions
   |-fno-inline-small-functions |-fno-inline-small-functions
   ||since
   ||r10-3575-g629387a6586a7531
 CC||ebotcazou at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org

--- Comment #4 from Martin Liška  ---
Started with r10-3575-g629387a6586a7531.