re PR tree-optimization/77988 (ICE on valid code at -Os and above on x86_64-linux-gnu: verify_gimple failed)

2016-10-17  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77988
	* tree-vrp.c (remove_range_assertions): Use replace_uses_by.

	* gcc.dg/torture/pr77988.c: New testcase.

From-SVN: r241242
This commit is contained in:
Richard Biener 2016-10-17 13:46:34 +00:00 committed by Richard Biener
parent a9260b7eb6
commit 44b00dbca0
4 changed files with 35 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2016-10-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/77988
* tree-vrp.c (remove_range_assertions): Use replace_uses_by.
2016-10-17 Marek Polacek <polacek@redhat.com>
* Makefile.in (C_COMMON_OBJS): Add c-family/c-attribs.o.

View file

@ -1,3 +1,8 @@
2016-10-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/77988
* gcc.dg/torture/pr77988.c: New testcase.
2016-10-17 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
* gcc.dg/pr71636-1.c: New test-case.

View file

@ -0,0 +1,24 @@
/* { dg-do compile } */
static int a = 2;
int b[1], c, d;
int main ()
{
int e = a, *f = &b[0];
if (d)
for (e = 0; e < 1; e++)
;
if (e)
{
L1:
if (b < f)
__builtin_abort ();
if (*f)
c++;
return 0;
}
f = 0;
goto L1;
return 0;
}

View file

@ -6882,7 +6882,6 @@ remove_range_assertions (void)
for (si = gsi_after_labels (bb), is_unreachable = -1; !gsi_end_p (si);)
{
gimple *stmt = gsi_stmt (si);
gimple *use_stmt;
if (is_gimple_assign (stmt)
&& gimple_assign_rhs_code (stmt) == ASSERT_EXPR)
@ -6890,8 +6889,6 @@ remove_range_assertions (void)
tree lhs = gimple_assign_lhs (stmt);
tree rhs = gimple_assign_rhs1 (stmt);
tree var;
use_operand_p use_p;
imm_use_iterator iter;
var = ASSERT_EXPR_VAR (rhs);
@ -6927,12 +6924,7 @@ remove_range_assertions (void)
}
/* Propagate the RHS into every use of the LHS. */
FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
{
FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
SET_USE (use_p, var);
update_stmt (use_stmt);
}
replace_uses_by (lhs, var);
/* And finally, remove the copy, it is not needed. */
gsi_remove (&si, true);