[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-30 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

Jakub Jelinek  changed:

   What|Removed |Added

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

--- Comment #9 from Jakub Jelinek  ---
Fixed.

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-30 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

--- Comment #8 from Jakub Jelinek  ---
Author: jakub
Date: Wed Oct 30 09:52:01 2019
New Revision: 277605

URL: https://gcc.gnu.org/viewcvs?rev=277605=gcc=rev
Log:
PR tree-optimization/92262
* tree-ssa-loop-ivopts.c (get_debug_computation_at): Don't unshare
ubase or cbase here.
(remove_unused_ivs): Unshare comp before using it.

* g++.dg/opt/pr92262.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/opt/pr92262.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-loop-ivopts.c

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

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 47125
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47125=edit
gcc10-pr92262.patch

Full patch I'm going to test.

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

--- Comment #6 from Jakub Jelinek  ---
Actually, to be precise, get_computation_at does unshare expressions, that is
done in unshare_aff_combination.  The problem is that afterwards
aff_combination_to_tree calls fold_build* and those invoke the various GENERIC
folders and those do not generally guarantee unsharing.
In particular, fold_binary_op_with_conditional_arg is eventually called, with
(sizetype) _5 + 18446744073709551609 <= (sizetype) _29 ? unsigned long) _29
- (unsigned long) _5) + 7) / 8 + 1) * 4 : 4
as op0 and (unsigned long)  as op1 and it adds the (unsigned long) 
operand to both the ... * 4 and 4 expressions and so appears twice.
Now, I'm not sure what the right fix is, because in theory this can happen in
lots of places.  Either fold-const.c could unshare_expr if it uses an operand
multiple times and it is during or after gimplification, or just various places
in GIMPLE which fold trees and then try to gimplify them need to unshare just
in case (especially because the gimplifier is destructive and when gimplifying
one copy it might clobber the other one), something else?

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

--- Comment #5 from Jakub Jelinek  ---
Actually I can, but for some reason I had to use explicit -fchecking, dunno how
I've configured this cross.
Anyway, I don't see a tree sharing issue in the newly added code, but
get_computation_at doesn't unshare, which can be perhaps ok with the way it is
used in non-debug stmts, but it is not ok for debug stmts.
Now, we could unshare_expr in get_debug_computation_at when get_computation_at
succeeds, but as we now iterate over possibly several IVs, I think it is better
to unshare only when we pick the best candidate.
So:
--- gcc/tree-ssa-loop-ivopts.c.jj   2019-10-23 14:35:42.994753407 +0200
+++ gcc/tree-ssa-loop-ivopts.c  2019-10-29 09:45:47.418217336 +0100
@@ -4152,8 +4152,6 @@ get_debug_computation_at (class loop *lo
   var = fold_convert (ctype, var);
 }

-  ubase = unshare_expr (ubase);
-  cbase = unshare_expr (cbase);
   if (stmt_after_increment (loop, cand, at))
 var = fold_build2 (MINUS_EXPR, TREE_TYPE (var), var,
   unshare_expr (cstep));
@@ -7648,6 +7646,7 @@ remove_unused_ivs (struct ivopts_data *d
  if (!best_cand)
continue;

+ comp = unshare_expr (comp);
  if (count > 1)
{
  tree vexpr = make_node (DEBUG_EXPR_DECL);

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-29 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

Martin Liška  changed:

   What|Removed |Added

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

--- Comment #4 from Martin Liška  ---
I can with:

$ ./xgcc -v
Using built-in specs.
COLLECT_GCC=./xgcc
Target: powerpc-e300c3-linux-gnu
Configured with: ../configure --enable-languages=c,c++
--prefix=/home/marxin/bin/gcc --disable-bootstrap --disable-multilib
--target=powerpc-e300c3-linux-gnu --without-isl
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.0.0 20191029 (experimental) (GCC) 

$ ./xg++ -B. ~/Programming/testcases/pr92262.c -c -O2 -ftree-loop-distribution
-fvar-tracking-assignments -fpermissive
/home/marxin/Programming/testcases/pr92262.c:10:2: warning: ‘operator new’
takes type ‘size_t’ (‘unsigned int’) as first parameter [-fpermissive]
   10 | *operator new (long unsigned int, void *as)
  |  ^~~~
/home/marxin/Programming/testcases/pr92262.c: In function ‘int main()’:
/home/marxin/Programming/testcases/pr92262.c:124:1: error: incorrect sharing of
tree nodes
  124 | main ()
  | ^~~~
(unsigned int) 
# DEBUG du => (int *) (((sizetype) _5 + 4294967293 <= (sizetype) _29 ?
unsigned int) _29 - (unsigned int) _5) + 3) / 4 + 1) * 4 + (unsigned int)
 : (unsigned int)  + 4) - doloop.30_51 * 4)
/home/marxin/Programming/testcases/pr92262.c:124:1: error: incorrect sharing of
tree nodes
(unsigned int) 
# DEBUG D#6 => (int *) sizetype) _5 + 4294967293 <= (sizetype) _29 ?
unsigned int) _29 - (unsigned int) _5) + 3) / 4 + 1) * 4 + (unsigned int)
 : (unsigned int)  + 4) - doloop.30_51 * 4) + 4)
during GIMPLE pass: ivopts
/home/marxin/Programming/testcases/pr92262.c:124:1: internal compiler error:
verify_gimple failed
0xfebd91 verify_gimple_in_cfg(function*, bool)
../../gcc/tree-cfg.c:5427
0xecc6bf execute_function_todo
../../gcc/passes.c:1983
0xecd46e execute_todo
../../gcc/passes.c:2037
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

--- Comment #3 from Jakub Jelinek  ---
I can't reproduce it on a cross to powerpc64-linux.

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-29 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

Richard Biener  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org
   Target Milestone|--- |10.0

--- Comment #2 from Richard Biener  ---
Very likely caused by Jakubs changes though.

[Bug tree-optimization/92262] [10 Regression] ICE: verify_gimple failed (error: incorrect sharing of tree nodes)

2019-10-29 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92262

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-10-29
 CC||marxin at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |marxin at gcc dot 
gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Martin Liška  ---
Confirmed, I can take a look.