From: Richard Biener Date: Wed, 12 Oct 2016 07:08:49 +0000 (+0000) Subject: re PR middle-end/77920 (186.crafty doesn't compile) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7dc2f5f1236a0f1544c756c46a5cd06491e96934;p=gcc.git re PR middle-end/77920 (186.crafty doesn't compile) 2016-10-12 Richard Biener 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f64bc62ed83..92a45d90cdc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2016-10-12 Richard Biener + + 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 PR tree-optimization/77929 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5605a3e972d..1ebd9bd01d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-12 Richard Biener + + PR tree-optimization/77920 + * gcc.dg/torture/pr77920.c: New testcase. + 2016-10-12 Jakub Jelinek PR tree-optimization/77929 diff --git a/gcc/testsuite/gcc.dg/torture/pr77920.c b/gcc/testsuite/gcc.dg/torture/pr77920.c new file mode 100644 index 00000000000..66ad5fc1248 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77920.c @@ -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; + } +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 8a129c6d704..e46f7fcf085 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -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;