===================================================================
@@ -9093,9 +9093,7 @@ simplify_div_or_mod_using_ranges (gimple
{
/* 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
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
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
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 *s
/* 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
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_
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_
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_
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;
===================================================================
@@ -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;
+ }
+}