diff options
author | Richard Biener <rguenther@suse.de> | 2017-08-08 12:51:20 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-08-08 12:51:20 +0000 |
commit | 51bd28edcbf49844d696c38af4945ce5fc25ba15 (patch) | |
tree | 84b27b7405d551358230e4089c5e12112127ce6f /gcc/tree-ssa-loop-niter.c | |
parent | 26d66f28fdb9bea6e05c2c9f9df7870f9d9f76b2 (diff) | |
download | gcc-51bd28edcbf49844d696c38af4945ce5fc25ba15.zip gcc-51bd28edcbf49844d696c38af4945ce5fc25ba15.tar.gz gcc-51bd28edcbf49844d696c38af4945ce5fc25ba15.tar.bz2 |
re PR middle-end/81719 (Range-based for loop on short fixed size array generates long unrolled loop)
2017-08-08 Richard Biener <rguenther@suse.de>
PR middle-end/81719
* tree-ssa-loop-niter.c: Include tree-dfa.h.
(expand_simple_operations): Also look through ADDR_EXPRs with
MEM_REF bases treating them as POINTER_PLUS_EXPR.
* g++.dg/tree-ssa/pr81719.C: New testcase.
From-SVN: r250954
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r-- | gcc/tree-ssa-loop-niter.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index e0107c2..0d6d101 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-chrec.h" #include "tree-scalar-evolution.h" #include "params.h" +#include "tree-dfa.h" /* The maximum number of dominator BBs we search for conditions @@ -1980,6 +1981,21 @@ expand_simple_operations (tree expr, tree stop) if (code == SSA_NAME) return expand_simple_operations (e, stop); + else if (code == ADDR_EXPR) + { + HOST_WIDE_INT offset; + tree base = get_addr_base_and_unit_offset (TREE_OPERAND (e, 0), + &offset); + if (base + && TREE_CODE (base) == MEM_REF) + { + ee = expand_simple_operations (TREE_OPERAND (base, 0), stop); + return fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (expr), ee, + wide_int_to_tree (sizetype, + mem_ref_offset (base) + + offset)); + } + } return expr; } |