[Bug tree-optimization/105618] [11/12/13 Regression] Missed loop body simplification by -O3 (trunk v.s. 10.3)

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

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

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

commit r13-550-gebce0e9bd8d714a8607ae24331a3d842b0d11859
Author: Richard Biener 
Date:   Tue May 17 09:45:02 2022 +0200

tree-optimization/105618 - restore load sinking

The PR97330 fix caused some missed sinking of loads out of loops
the following patch re-instantiates.

2022-05-17  Richard Biener  

PR tree-optimization/105618
* tree-ssa-sink.cc (statement_sink_location): For virtual
PHI uses ignore those defining the used virtual operand.

* gcc.dg/tree-ssa/ssa-sink-19.c: New testcase.

[Bug tree-optimization/105618] [11/12/13 Regression] Missed loop body simplification by -O3 (trunk v.s. 10.3)

2022-05-17 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105618

Richard Biener  changed:

   What|Removed |Added

   Keywords|needs-bisection |

--- Comment #4 from Richard Biener  ---
I'm testing a patch.

[Bug tree-optimization/105618] [11/12/13 Regression] Missed loop body simplification by -O3 (trunk v.s. 10.3)

2022-05-17 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105618

--- Comment #3 from Richard Biener  ---
There was quite some massaging in handling of PHI uses, notably we now have

  /* For PHI nodes the block we know sth about is the incoming
block
 with the use.  */
  if (gimple_code (use_stmt) == GIMPLE_PHI)
{
  /* In case the PHI node post-dominates the current insert
 location we can disregard it.  But make sure it is not
 dominating it as well as can happen in a CFG cycle.  */
  if (commondom != bb
  && !dominated_by_p (CDI_DOMINATORS, commondom, bb)
  && dominated_by_p (CDI_POST_DOMINATORS, commondom, bb)
  /* If the blocks are possibly within the same irreducible
 cycle the above check breaks down.  */
  && !((bb->flags & commondom->flags & BB_IRREDUCIBLE_LOOP)
   && bb->loop_father == commondom->loop_father)
  && !((commondom->flags & BB_IRREDUCIBLE_LOOP)
   && flow_loop_nested_p (commondom->loop_father,
  bb->loop_father))
  && !((bb->flags & BB_IRREDUCIBLE_LOOP)
   && flow_loop_nested_p (bb->loop_father,
  commondom->loop_father)))
continue;

and already the first !dominated_by_p (CDI_DOMINATORS, commondom, bb) check
makes us not consider the sink opportunity.  That was introduced as part
of the fix for PR97330.

[Bug tree-optimization/105618] [11/12/13 Regression] Missed loop body simplification by -O3 (trunk v.s. 10.3)

2022-05-17 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105618

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
Summary|Missed loop body|[11/12/13 Regression]
   |simplification by -O3   |Missed loop body
   |(trunk v.s. 10.3)   |simplification by -O3
   ||(trunk v.s. 10.3)
   Target Milestone|--- |11.4
   Last reconfirmed||2022-05-17
   Keywords||missed-optimization,
   ||needs-bisection
  Known to fail||11.3.1, 12.1.1
 Ever confirmed|0   |1
  Known to work||10.3.1
 Status|UNCONFIRMED |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #2 from Richard Biener  ---
Confirmed.  GCC 10 manages to sink the load from e out of the loop while GCC 12
fails to do that.