[Bug tree-optimization/103690] [12 Regression] ICE: in build2, at tree.c:4985 with -g -O2 -fno-tree-dce -fno-tree-dse -fno-tree-fre --param=max-jump-thread-duplication-stmts=94 since r12-2591-g2e96b5f

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

Richard Biener  changed:

   What|Removed |Added

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

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

[Bug tree-optimization/103690] [12 Regression] ICE: in build2, at tree.c:4985 with -g -O2 -fno-tree-dce -fno-tree-dse -fno-tree-fre --param=max-jump-thread-duplication-stmts=94 since r12-2591-g2e96b5f

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

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

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

commit r12-6208-gebc853deb7cc0487de9ef6e891a007ba853d1933
Author: Richard Biener 
Date:   Tue Jan 4 11:59:35 2022 +0100

tree-optimization/103690 - not up-to-date SSA and PRE DCE

This avoids running simple_dce_from_worklist on partially not up-to-date
SSA form (in unreachable code regions) by scheduling CFG cleanup
manually as is done anyway when tail-merging runs.

2022-01-04  Richard Biener  

PR tree-optimization/103690
* tree-pass.h (tail_merge_optimize): Adjust.
* tree-ssa-tail-merge.c (tail_merge_optimize): Pass in whether
to re-split critical edges, move CFG cleanup ...
* tree-ssa-pre.c (pass_pre::execute): ... here, before
simple_dce_from_worklist and delay freeing inserted_exprs from
...
(fini_pre): .. here.

[Bug tree-optimization/103690] [12 Regression] ICE: in build2, at tree.c:4985 with -g -O2 -fno-tree-dce -fno-tree-dse -fno-tree-fre --param=max-jump-thread-duplication-stmts=94 since r12-2591-g2e96b5f

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

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #6 from Richard Biener  ---
Value numbering stmt = __trans_tmp_1_14 = _24 + 4;
Setting value number of __trans_tmp_1_14 to __trans_tmp_1_22 (changed)

what we do is avoiding useless work during elimination, not visiting if (0)
guarded code - those regions will have not up-to-date SSA form.

Block 14: BB5 found not executable

the issue is that PRE does

  /* Because we don't follow exactly the standard PRE algorithm, and decide not
 to insert PHI nodes sometimes, and because value numbering of casts isn't
 perfect, we sometimes end up inserting dead code.   This simple DCE-like
 pass removes any insertions we made that weren't actually used.  */
  simple_dce_from_worklist (inserted_exprs);

which eventually runs into those uses for expressions we inserted into those
unreachable blocks.

The issue is long latent I think.

[Bug tree-optimization/103690] [12 Regression] ICE: in build2, at tree.c:4985 with -g -O2 -fno-tree-dce -fno-tree-dse -fno-tree-fre --param=max-jump-thread-duplication-stmts=94 since r12-2591-g2e96b5f

2021-12-16 Thread aldyh at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103690

--- Comment #5 from Aldy Hernandez  ---
(In reply to Andrew Pinski from comment #2)
> (gdb) p debug_gimple_stmt(stmt)
> _67 = _14 + _66;
> 
> 
> Before pre had:
>   intD.9 * __trans_tmp_1D.2946;
> 
>   # RANGE [1, 9223372036854775807] NONZERO 9223372036854775804
>   _66 = (long unsigned intD.16) _17;
>   # PT = nonlocal escaped
>   # ALIGN = 4, MISALIGN = 0
>   _67 = __trans_tmp_1_14 + _66;
> 
> But after:
>   # RANGE [1, 9223372036854775807] NONZERO 9223372036854775804
>   _66 = (long unsigned intD.16) _17;
>   # PT = nonlocal escaped
>   # ALIGN = 4, MISALIGN = 0
>   _67 = _14 + _66;
> 
> We already removed the definition of _14 too:
> Removing dead stmt __trans_tmp_1_14 = _24 + 4;
> 
> So it is the order of the removal which is causing issues.

Why is PRE removing the DEF of _14 when there are still uses?

   [local count: 69834]:
  __count.1_62 = (long unsigned int) _11;
  __builtin_memmove (_14, _9, __count.1_62);
  _66 = (long unsigned int) _17;
  _67 = _14 + _66;
...

[Bug tree-optimization/103690] [12 Regression] ICE: in build2, at tree.c:4985 with -g -O2 -fno-tree-dce -fno-tree-dse -fno-tree-fre --param=max-jump-thread-duplication-stmts=94 since r12-2591-g2e96b5f

2021-12-15 Thread acoplan at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103690

Alex Coplan  changed:

   What|Removed |Added

 CC||acoplan at gcc dot gnu.org

--- Comment #4 from Alex Coplan  ---
Here's a slightly cleaned up testcase which fails with the same options FWIW:

typedef int *int_ptr;
struct __normal_iterator {
  int *_M_current;
  __normal_iterator(const int_ptr &__i) : _M_current(__i) {}
  void foo() { __normal_iterator(_M_current - 1); }
};
void deallocate(int *);
struct vector {
  int *_M_start;
  int *_M_finish;
  __normal_iterator end() { return _M_finish; }
  int back() {
__normal_iterator t = _M_finish;
t.foo();
  }
  void foo();
};
int *p1, *p2;
int last, result;
void vector::foo() {
  for (int i; i;)
while (i) {
  __normal_iterator t1 = end();
  int *p3, *__old_start = _M_start, *__new_finish;
  long __count =  - __old_start;
  if (__count > 0)
__builtin_memmove(, __old_start, __count);
  p1 =  + __count;
  p2 = p1 + 1;
  __count = _M_finish - t1._M_current;
  if (__count)
__builtin_memmove(p2, t1._M_current, __count);
  p3 = p2 + __count;
  __new_finish = p3;
  if (__old_start)
deallocate(__old_start);
  _M_finish = __new_finish;
  back();
}
}

also confirmed on aarch64-linux-gnu.

[Bug tree-optimization/103690] [12 Regression] ICE: in build2, at tree.c:4985 with -g -O2 -fno-tree-dce -fno-tree-dse -fno-tree-fre --param=max-jump-thread-duplication-stmts=94 since r12-2591-g2e96b5f

2021-12-14 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103690

Martin Liška  changed:

   What|Removed |Added

 CC||aldyh at gcc dot gnu.org,
   ||amacleod at redhat dot com,
   ||marxin at gcc dot gnu.org
Summary|[12 Regression] ICE: in |[12 Regression] ICE: in
   |build2, at tree.c:4985 with |build2, at tree.c:4985 with
   |-g -O2 -fno-tree-dce|-g -O2 -fno-tree-dce
   |-fno-tree-dse -fno-tree-fre |-fno-tree-dse -fno-tree-fre
   |--param=max-jump-thread-dup |--param=max-jump-thread-dup
   |lication-stmts=94   |lication-stmts=94 since
   ||r12-2591-g2e96b5f14e402569

--- Comment #3 from Martin Liška  ---
Started with r12-2591-g2e96b5f14e402569.