From 0139ba9332f80bad92794bcd4bfe360f2cfc42a4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 17 May 2016 19:50:55 +0200 Subject: [PATCH] VRP: range info of new variables 2016-05-17 Marc Glisse gcc/ * tree-vrp.c (simplify_truth_ops_using_ranges): Set range information for new SSA_NAME. (simplify_conversion_using_ranges): Get range through get_range_info instead of get_value_range. gcc/testsuite/ * gcc.dg/tree-ssa/pr69270.c: Adjust. * gcc.dg/tree-ssa/vrp99.c: New testcase. From-SVN: r236336 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/pr69270.c | 2 -- gcc/testsuite/gcc.dg/tree-ssa/vrp99.c | 9 +++++++++ gcc/tree-vrp.c | 21 ++++++++++++--------- 5 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vrp99.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b1d1bc022bc..93c1a2d22a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-05-17 Marc Glisse + + * tree-vrp.c (simplify_truth_ops_using_ranges): Set range + information for new SSA_NAME. + (simplify_conversion_using_ranges): Get range through get_range_info + instead of get_value_range. + 2016-05-17 Jiong Wang * config/aarch64/arm_neon.h (vmvn_s8): Reimplement using C operator. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b507061213b..ca093a18527 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-17 Marc Glisse + + * gcc.dg/tree-ssa/pr69270.c: Adjust. + * gcc.dg/tree-ssa/vrp99.c: New testcase. + 2016-05-17 Jiong Wang * gcc.target/aarch64/simd/vmul_elem_1.c: Use intrinsics. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr69270.c b/gcc/testsuite/gcc.dg/tree-ssa/pr69270.c index 28f6d0fac28..0d66cc4383f 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr69270.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr69270.c @@ -7,8 +7,6 @@ /* { dg-final { scan-tree-dump-times "Replaced .bufferstep_\[0-9\]+. with constant .1." 1 "dom3"} } */ /* And some assignments ought to fold down to constants. */ -/* { dg-final { scan-tree-dump-times "Folded to: _\[0-9\]+ = -1;" 1 "dom3"} } */ -/* { dg-final { scan-tree-dump-times "Folded to: _\[0-9\]+ = -2;" 1 "dom3"} } */ /* { dg-final { scan-tree-dump-times "Folded to: _\[0-9\]+ = 1;" 1 "dom3"} } */ /* { dg-final { scan-tree-dump-times "Folded to: _\[0-9\]+ = 0;" 1 "dom3"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp99.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp99.c new file mode 100644 index 00000000000..baa7a706fd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp99.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1" } */ + +unsigned f(unsigned i){ + i >>= __SIZEOF_INT__ * __CHAR_BIT__ - 1; + return i == 0; +} + +/* { dg-final { scan-tree-dump-not "\\(unsigned int\\)" "vrp1" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 4cd1ab30b30..69e6248a4fc 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -8940,6 +8940,11 @@ simplify_truth_ops_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt) gassign *newop = gimple_build_assign (tem, BIT_XOR_EXPR, op0, op1); gsi_insert_before (gsi, newop, GSI_SAME_STMT); + if (INTEGRAL_TYPE_P (TREE_TYPE (tem)) + && TYPE_PRECISION (TREE_TYPE (tem)) > 1) + set_range_info (tem, VR_RANGE, + wi::zero (TYPE_PRECISION (TREE_TYPE (tem))), + wi::one (TYPE_PRECISION (TREE_TYPE (tem)))); gimple_assign_set_rhs_with_ops (gsi, NOP_EXPR, tem); } /* Or without. */ @@ -9648,7 +9653,6 @@ simplify_conversion_using_ranges (gimple *stmt) { tree innerop, middleop, finaltype; gimple *def_stmt; - value_range *innervr; signop inner_sgn, middle_sgn, final_sgn; unsigned inner_prec, middle_prec, final_prec; widest_int innermin, innermed, innermax, middlemin, middlemed, middlemax; @@ -9666,18 +9670,17 @@ simplify_conversion_using_ranges (gimple *stmt) || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (innerop)) return false; - /* Get the value-range of the inner operand. */ - innervr = get_value_range (innerop); - if (innervr->type != VR_RANGE - || TREE_CODE (innervr->min) != INTEGER_CST - || TREE_CODE (innervr->max) != INTEGER_CST) + /* Get the value-range of the inner operand. Use get_range_info in + case innerop was created during substitute-and-fold. */ + wide_int imin, imax; + if (!INTEGRAL_TYPE_P (TREE_TYPE (innerop)) + || get_range_info (innerop, &imin, &imax) != VR_RANGE) return false; + innermin = widest_int::from (imin, TYPE_SIGN (TREE_TYPE (innerop))); + innermax = widest_int::from (imax, TYPE_SIGN (TREE_TYPE (innerop))); /* Simulate the conversion chain to check if the result is equal if the middle conversion is removed. */ - innermin = wi::to_widest (innervr->min); - innermax = wi::to_widest (innervr->max); - inner_prec = TYPE_PRECISION (TREE_TYPE (innerop)); middle_prec = TYPE_PRECISION (TREE_TYPE (middleop)); final_prec = TYPE_PRECISION (finaltype); -- 2.30.2