diff options
author | Alexander Ivchenko <alexander.ivchenko@intel.com> | 2015-01-28 14:16:01 +0300 |
---|---|---|
committer | Alexander Ivchenko <alexander.ivchenko@intel.com> | 2015-01-28 15:41:39 +0300 |
commit | 63fd708bd182b50b37b9f64fa330458c9109380a (patch) | |
tree | 2799a45bf3f48cd9f4039d79aa82b5c0b2189f6a /gcc-4.9/gcc/tree-ssa-loop-niter.c | |
parent | 866bd0b46cd84957df84e7a3e674d9777807b7f7 (diff) | |
download | toolchain_gcc-63fd708bd182b50b37b9f64fa330458c9109380a.tar.gz toolchain_gcc-63fd708bd182b50b37b9f64fa330458c9109380a.tar.bz2 toolchain_gcc-63fd708bd182b50b37b9f64fa330458c9109380a.zip |
[4.9] Fix bogus warnings about array-bounds.
2015-01-28 Ilya Enkovich <ilya.enkovich@intel.com>
PR tree-optimization/64277
* tree-ssa-loop-niter.c (record_nonwrapping_iv): Use base
range info when possible to refine estimation.
2015-01-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/56273
PR tree-optimization/59124
PR tree-optimization/64277
* tree-vrp.c (vrp_finalize): Emit array-bound warnings only
from the first VRP pass.
* g++.dg/warn/Warray-bounds-6.C: New testcase.
* gcc.dg/Warray-bounds-12.c: Likewise.
* gcc.dg/Warray-bounds-13.c: Likewise.
Change-Id: I175b420a4c8150ecf986d477e4c51cbbff276c82
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
Diffstat (limited to 'gcc-4.9/gcc/tree-ssa-loop-niter.c')
-rw-r--r-- | gcc-4.9/gcc/tree-ssa-loop-niter.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc-4.9/gcc/tree-ssa-loop-niter.c b/gcc-4.9/gcc/tree-ssa-loop-niter.c index 7628363cc..62175f344 100644 --- a/gcc-4.9/gcc/tree-ssa-loop-niter.c +++ b/gcc-4.9/gcc/tree-ssa-loop-niter.c @@ -2724,6 +2724,7 @@ record_nonwrapping_iv (struct loop *loop, tree base, tree step, gimple stmt, tree niter_bound, extreme, delta; tree type = TREE_TYPE (base), unsigned_type; double_int max; + tree orig_base = base; if (TREE_CODE (step) != INTEGER_CST || integer_zerop (step)) return; @@ -2747,7 +2748,14 @@ record_nonwrapping_iv (struct loop *loop, tree base, tree step, gimple stmt, if (tree_int_cst_sign_bit (step)) { + double_int min, max; extreme = fold_convert (unsigned_type, low); + if (TREE_CODE (orig_base) == SSA_NAME + && TREE_CODE (high) == INTEGER_CST + && INTEGRAL_TYPE_P (TREE_TYPE (orig_base)) + && get_range_info (orig_base, &min, &max) == VR_RANGE + && max.slt (TREE_INT_CST (high))) + base = double_int_to_tree (unsigned_type, max); if (TREE_CODE (base) != INTEGER_CST) base = fold_convert (unsigned_type, high); delta = fold_build2 (MINUS_EXPR, unsigned_type, base, extreme); @@ -2755,8 +2763,15 @@ record_nonwrapping_iv (struct loop *loop, tree base, tree step, gimple stmt, } else { + double_int min, max; extreme = fold_convert (unsigned_type, high); - if (TREE_CODE (base) != INTEGER_CST) + if (TREE_CODE (orig_base) == SSA_NAME + && TREE_CODE (low) == INTEGER_CST + && INTEGRAL_TYPE_P (TREE_TYPE (orig_base)) + && get_range_info (orig_base, &min, &max) == VR_RANGE + && min.sgt (TREE_INT_CST (low))) + base = double_int_to_tree (unsigned_type, min); + else if (TREE_CODE (base) != INTEGER_CST) base = fold_convert (unsigned_type, low); delta = fold_build2 (MINUS_EXPR, unsigned_type, extreme, base); } |