From 0011af7b9dce859b28a4dbdce2dff6d081193ddd Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Thu, 13 Oct 2016 01:26:28 +0000 Subject: [PATCH] EVRP - Push op1 value range before pushing op0 value range. gcc/ChangeLog: 2016-10-12 Richard Biener * tree-vrp.c (evrp_dom_walker::try_find_new_range): Renamed from try_add_new_range and made to eturn new range. (evrp_dom_walker::before_dom_children): Push op1 value range before pushing op0 value range. gcc/testsuite/ChangeLog: 2016-10-12 Kugan Vivekanandarajah * gcc.dg/tree-ssa/evrp6.c: New test. From-SVN: r241083 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/tree-ssa/evrp6.c | 22 ++++++++++++++++++++++ gcc/tree-vrp.c | 20 +++++++++++++------- 4 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/evrp6.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 600700a3945..922a0b60045 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-10-12 Richard Biener + + * tree-vrp.c (evrp_dom_walker::try_find_new_range): Renamed from + try_add_new_range and made to eturn new range. + (evrp_dom_walker::before_dom_children): Push op1 value range before + pushing op0 value range. + 2016-10-12 Bill Schmidt PR tree-optimization/77937 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5eb693a652f..e0d4f0bfb97 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-10-12 Kugan Vivekanandarajah + + * gcc.dg/tree-ssa/evrp6.c: New test. + 2016-10-12 Segher Boessenkool * gcc.target/powerpc/shrink-wrap-separate-0.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp6.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp6.c new file mode 100644 index 00000000000..35d4d7459de --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp6.c @@ -0,0 +1,22 @@ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +extern void abort (void); + +int +foo (int k, int j) +{ + if (j >= 10) + { + if (j < k) + { + k++; + if (k < 10) + abort (); + } + } + + return j; +} +/* { dg-final { scan-tree-dump "\\\[12, \\+INF" "evrp" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 8d5fa66e084..941c0fd34d8 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -10646,7 +10646,7 @@ public: virtual void after_dom_children (basic_block); void push_value_range (const_tree var, value_range *vr); value_range *pop_value_range (const_tree var); - void try_add_new_range (tree op, tree_code code, tree limit); + value_range *try_find_new_range (tree op, tree_code code, tree limit); /* Cond_stack holds the old VR. */ auto_vec > stack; @@ -10655,10 +10655,10 @@ public: }; -/* Add new range to OP such that (OP CODE LIMIT) is true. */ +/* Find new range for OP such that (OP CODE LIMIT) is true. */ -void -evrp_dom_walker::try_add_new_range (tree op, tree_code code, tree limit) +value_range * +evrp_dom_walker::try_find_new_range (tree op, tree_code code, tree limit) { value_range vr = VR_INITIALIZER; value_range *old_vr = get_value_range (op); @@ -10674,8 +10674,9 @@ evrp_dom_walker::try_add_new_range (tree op, tree_code code, tree limit) { value_range *new_vr = vrp_value_range_pool.allocate (); *new_vr = vr; - push_value_range (op, new_vr); + return new_vr; } + return NULL; } /* See if there is any new scope is entered with new VR and set that VR to @@ -10711,7 +10712,7 @@ evrp_dom_walker::before_dom_children (basic_block bb) code = invert_tree_comparison (gimple_cond_code (stmt), HONOR_NANS (op0)); /* Add VR when (OP0 CODE OP1) condition is true. */ - try_add_new_range (op0, code, op1); + value_range *op0_range = try_find_new_range (op0, code, op1); /* Register ranges for y in x < y where y might have ranges that are useful. */ @@ -10724,8 +10725,13 @@ evrp_dom_walker::before_dom_children (basic_block bb) &new_code, &limit)) { /* Add VR when (OP1 NEW_CODE LIMIT) condition is true. */ - try_add_new_range (op1, new_code, limit); + value_range *op1_range = try_find_new_range (op1, new_code, limit); + if (op1_range) + push_value_range (op1, op1_range); } + + if (op0_range) + push_value_range (op0, op0_range); } } -- 2.30.2