re PR middle-end/77920 (186.crafty doesn't compile)

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

	PR tree-optimization/77920
	* tree-vrp.c (simplify_div_or_mod_using_ranges): Simplify.
	(simplify_min_or_max_using_ranges): Pass in gsi and use it.
	(simplify_abs_using_ranges): Likewise.
	(simplify_conversion_using_ranges): Likewise.
	(simplify_stmt_using_ranges): Adjust.

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

From-SVN: r241020
This commit is contained in:
Richard Biener 2016-10-12 07:08:49 +00:00 committed by Richard Biener
parent 4a8b97cb8a
commit 7dc2f5f123
4 changed files with 41 additions and 17 deletions

View File

@ -1,3 +1,12 @@
2016-10-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/77920
* tree-vrp.c (simplify_div_or_mod_using_ranges): Simplify.
(simplify_min_or_max_using_ranges): Pass in gsi and use it.
(simplify_abs_using_ranges): Likewise.
(simplify_conversion_using_ranges): Likewise.
(simplify_stmt_using_ranges): Adjust.
2016-10-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/77929

View File

@ -1,3 +1,8 @@
2016-10-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/77920
* gcc.dg/torture/pr77920.c: New testcase.
2016-10-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/77929

View File

@ -0,0 +1,17 @@
/* { dg-do compile } */
int a, b;
void fn1()
{
int c;
for (; b < 0;)
{
{
int d = 56, e = (b >> 3) - (d >> 3) > 0 ? (b >> 3) - (d >> 3)
: -((b >> 3) - (d >> 3));
c = 1 >= e;
}
if (c)
a = 0;
}
}

View File

@ -9093,9 +9093,7 @@ simplify_div_or_mod_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
{
/* If op0 already has the range op0 % op1 has,
then TRUNC_MOD_EXPR won't change anything. */
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
gimple_assign_set_rhs_from_tree (&gsi, op0);
update_stmt (stmt);
gimple_assign_set_rhs_from_tree (gsi, op0);
return true;
}
}
@ -9171,7 +9169,7 @@ simplify_div_or_mod_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
disjoint. Return true if we do simplify. */
static bool
simplify_min_or_max_using_ranges (gimple *stmt)
simplify_min_or_max_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
{
tree op0 = gimple_assign_rhs1 (stmt);
tree op1 = gimple_assign_rhs2 (stmt);
@ -9206,10 +9204,7 @@ simplify_min_or_max_using_ranges (gimple *stmt)
VAL == FALSE -> OP0 > or >= op1. */
tree res = ((gimple_assign_rhs_code (stmt) == MAX_EXPR)
== integer_zerop (val)) ? op0 : op1;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
gimple_assign_set_rhs_from_tree (&gsi, res);
update_stmt (stmt);
fold_stmt (&gsi, follow_single_use_edges);
gimple_assign_set_rhs_from_tree (gsi, res);
return true;
}
@ -9221,7 +9216,7 @@ simplify_min_or_max_using_ranges (gimple *stmt)
ABS_EXPR into a NEGATE_EXPR. */
static bool
simplify_abs_using_ranges (gimple *stmt)
simplify_abs_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
{
tree op = gimple_assign_rhs1 (stmt);
value_range *vr = get_value_range (op);
@ -9262,8 +9257,7 @@ simplify_abs_using_ranges (gimple *stmt)
else
gimple_assign_set_rhs_code (stmt, NEGATE_EXPR);
update_stmt (stmt);
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
fold_stmt (&gsi, follow_single_use_edges);
fold_stmt (gsi, follow_single_use_edges);
return true;
}
}
@ -9844,7 +9838,7 @@ simplify_switch_using_ranges (gswitch *stmt)
/* Simplify an integral conversion from an SSA name in STMT. */
static bool
simplify_conversion_using_ranges (gimple *stmt)
simplify_conversion_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
{
tree innerop, middleop, finaltype;
gimple *def_stmt;
@ -9914,8 +9908,7 @@ simplify_conversion_using_ranges (gimple *stmt)
return false;
gimple_assign_set_rhs1 (stmt, innerop);
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
fold_stmt (&gsi, follow_single_use_edges);
fold_stmt (gsi, follow_single_use_edges);
return true;
}
@ -10218,7 +10211,7 @@ simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
case ABS_EXPR:
if (TREE_CODE (rhs1) == SSA_NAME
&& INTEGRAL_TYPE_P (TREE_TYPE (rhs1)))
return simplify_abs_using_ranges (stmt);
return simplify_abs_using_ranges (gsi, stmt);
break;
case BIT_AND_EXPR:
@ -10233,7 +10226,7 @@ simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
CASE_CONVERT:
if (TREE_CODE (rhs1) == SSA_NAME
&& INTEGRAL_TYPE_P (TREE_TYPE (rhs1)))
return simplify_conversion_using_ranges (stmt);
return simplify_conversion_using_ranges (gsi, stmt);
break;
case FLOAT_EXPR:
@ -10244,7 +10237,7 @@ simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
case MIN_EXPR:
case MAX_EXPR:
return simplify_min_or_max_using_ranges (stmt);
return simplify_min_or_max_using_ranges (gsi, stmt);
default:
break;