[Bug c/86046] [9 Regression] ICE in execute_todo, at passes.c:2043

2018-06-05 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86046

Richard Biener  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #3 from Richard Biener  ---
Fixed.

[Bug c/86046] [9 Regression] ICE in execute_todo, at passes.c:2043

2018-06-05 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86046

--- Comment #2 from Richard Biener  ---
Author: rguenth
Date: Tue Jun  5 10:02:50 2018
New Revision: 261193

URL: https://gcc.gnu.org/viewcvs?rev=261193=gcc=rev
Log:
2018-06-05  Richard Biener  

PR tree-optimization/86046
* tree-ssa.c (maybe_optimize_var): Clear DECL_GIMPLE_REG_P
if required after clearing TREE_ADDRESSABLE.

* gcc.dg/pr86046.c: New testcase.

Added:
trunk/gcc/testsuite/gcc.dg/pr86046.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa.c

[Bug c/86046] [9 Regression] ICE in execute_todo, at passes.c:2043

2018-06-05 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86046

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2018-06-05
   Target Milestone|--- |9.0
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
Confirmed.  After CCP:

No longer having address taken: D.1960

but then we fail to rewrite it.

  VIEW_CONVERT_EXPR(D.1960)[1] = 0;

Ah, so the issue seems to be that D.1960 is already DECL_GIMPLE_REG_P but
it is just TREE_ADDRESSABLE avoiding the rewriting need.  But
update_address_taken simply clears TREE_ADDRESSABLE but leaves
DECL_GIMPLE_REG_P
in place thinking it cannot be set.

The issue may be premature setting of DECL_GIMPLE_REG_P but we can work around
this in update_address_taken.

There's a missed optimization as well, we expect to rewrite the array-ref into
a bitfield ref during gimplification.  Ah, but we avoid doing that for
the out-of-bound access this is.