[Bug tree-optimization/105198] [9/10 Regression] Wrong code for C loop (GCC 12 -O2, GCC 11 -O3)

2022-05-06 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105198

--- Comment #12 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Richard Biener
:

https://gcc.gnu.org/g:29e8fe04e707910b1bcf15cbc2b582ee0e0e93d6

commit r10-10595-g29e8fe04e707910b1bcf15cbc2b582ee0e0e93d6
Author: Richard Biener 
Date:   Fri Apr 8 13:13:29 2022 +0200

tree-optimization/105198 - wrong code with predictive commoning

When predictive commoning looks for a looparound PHI it tries
to match the entry value definition (a load) up with the appropriate
member of the chain.  But it fails to consider stmts clobbering
the very same memory location inbetween the load and loop entry.

In theory we could be more clever on must aliases that would be
also picked up from a load (so not exactly stmt_kills_ref_p) and
use the stored value from that if it is an exact match.  But we
currently have no way to propagate this information inside predcom.

2022-04-08  Richard Biener  

PR tree-optimization/105198
* tree-predcom.c (find_looparound_phi): Check whether
the found memory location of the entry value is clobbered
inbetween the value we want to use and loop entry.

* gcc.dg/torture/pr105198.c: New testcase.

(cherry picked from commit e5453bcc217ea4ac53a4ac277661d6ef0ccd425b)

[Bug tree-optimization/105198] [9/10 Regression] Wrong code for C loop (GCC 12 -O2, GCC 11 -O3)

2022-04-08 Thread tomas.kalibera at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105198

--- Comment #11 from Tomas Kalibera  ---
Thanks for the very quick fix! I confirm that when R is built with the fixed
version of GCC 12, the R testcase for MASS is fixed, it works with -O2.

[Bug tree-optimization/105198] [9/10 Regression] Wrong code for C loop (GCC 12 -O2, GCC 11 -O3)

2022-04-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105198

Richard Biener  changed:

   What|Removed |Added

Summary|[9/10/11 Regression] Wrong  |[9/10 Regression] Wrong
   |code for C loop (GCC 12 |code for C loop (GCC 12
   |-O2, GCC 11 -O3)|-O2, GCC 11 -O3)
  Known to fail||11.2.0
  Known to work||11.2.1, 12.0

--- Comment #10 from Richard Biener  ---
Fixed where the testcase fails, I'll eventually backport further for the latent
issue.