[Bug c/84873] [6/7/8 Regression] ICE: verify_ssa failed (error: definition in block 3 does not dominate use in block 4)

2018-03-15 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84873

--- Comment #8 from Richard Biener  ---
Author: rguenth
Date: Thu Mar 15 13:10:24 2018
New Revision: 258556

URL: https://gcc.gnu.org/viewcvs?rev=258556=gcc=rev
Log:
2018-03-15  Richard Biener  

PR c/84873
* c-gimplify.c (c_gimplify_expr): Do not fold expressions.

* c-c++-common/pr84873.c: New testcase.

Added:
trunk/gcc/testsuite/c-c++-common/pr84873.c
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-gimplify.c
trunk/gcc/testsuite/ChangeLog

[Bug c/84873] [6/7/8 Regression] ICE: verify_ssa failed (error: definition in block 3 does not dominate use in block 4)

2018-03-15 Thread rguenther at suse dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84873

--- Comment #7 from rguenther at suse dot de  ---
On Thu, 15 Mar 2018, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84873
> 
> --- Comment #6 from Jakub Jelinek  ---
> Why the
> +   if (TREE_CODE (*op1_p) == INTEGER_CST)
> + *op1_p = fold_convert (unsigned_type_node, *op1_p);
> +   else
> + *op1_p = build1 (NOP_EXPR, unsigned_type_node, *op1_p);
> ?  Just change the convert to fold_convert...  I hope the FE ensures that the
> shift count has a sane type (some integral one).

Because it's fold_binary_op_with_conditional_arg which introduces
the tree sharing.  So if, say, *op1_p was (long)  (x == 0) + (long) y
then fold_convert will fold away the conversion and re-fold the
PLUS which then may reach fold_binary_op_with_conditional_arg again.

I might have used

  tree tem = fold_unary_to_constant (...);
  if (!tem)
tem = build1 (...);
  *op1_p = tem;

but fold_unary_to_constant uses TREE_CONSTANT as well ...
(but it looks like COND_EXPR will never be TREE_CONSTANT at least).

[Bug c/84873] [6/7/8 Regression] ICE: verify_ssa failed (error: definition in block 3 does not dominate use in block 4)

2018-03-15 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84873

--- Comment #6 from Jakub Jelinek  ---
Why the
+   if (TREE_CODE (*op1_p) == INTEGER_CST)
+ *op1_p = fold_convert (unsigned_type_node, *op1_p);
+   else
+ *op1_p = build1 (NOP_EXPR, unsigned_type_node, *op1_p);
?  Just change the convert to fold_convert...  I hope the FE ensures that the
shift count has a sane type (some integral one).

[Bug c/84873] [6/7/8 Regression] ICE: verify_ssa failed (error: definition in block 3 does not dominate use in block 4)

2018-03-15 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84873

Richard Biener  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org
  Known to work||4.8.5
   Target Milestone|7.4 |6.5
  Known to fail||5.5.0, 6.4.0

--- Comment #5 from Richard Biener  ---
So the real bad commit was r218142.

[Bug c/84873] [6/7/8 Regression] ICE: verify_ssa failed (error: definition in block 3 does not dominate use in block 4)

2018-03-15 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84873

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
Summary|[7/8 Regression] ICE:   |[6/7/8 Regression] ICE:
   |verify_ssa failed (error:   |verify_ssa failed (error:
   |definition in block 3 does  |definition in block 3 does
   |not dominate use in block   |not dominate use in block
   |4)  |4)