diff options
author | alalaw01 <alalaw01@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-05 18:39:38 +0000 |
---|---|---|
committer | alalaw01 <alalaw01@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-05 18:39:38 +0000 |
commit | 7eef40851b74e8c3d788f97c22fd8d2b738062ae (patch) | |
tree | 65aac17b5f145eda4e33e8de39b0b5c8ca339191 /gcc/tree-scalar-evolution.c | |
parent | f480ca9a32a6bd50f858d4c70363869c8caf8f0d (diff) | |
download | gcc-7eef40851b74e8c3d788f97c22fd8d2b738062ae.tar.gz |
[PATCH] tree-scalar-evolution.c: Handle LSHIFT by constant
gcc/:
PR tree-optimization/65963
* tree-scalar-evolution.c (interpret_rhs_expr): Try to handle
LSHIFT_EXPRs as equivalent unsigned MULT_EXPRs.
gcc/testsuite/:
* gcc.dg/pr68112.c: New.
* gcc.dg/vect/vect-strided-shift-1.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229825 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index bb27b070dba..5cd7b1522ba 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1827,6 +1827,23 @@ interpret_rhs_expr (struct loop *loop, gimple *at_stmt, res = chrec_fold_multiply (type, chrec1, chrec2); break; + case LSHIFT_EXPR: + { + /* Handle A<<B as A * (1<<B). */ + tree uns = unsigned_type_for (type); + chrec1 = analyze_scalar_evolution (loop, rhs1); + chrec2 = analyze_scalar_evolution (loop, rhs2); + chrec1 = chrec_convert (uns, chrec1, at_stmt); + chrec1 = instantiate_parameters (loop, chrec1); + chrec2 = instantiate_parameters (loop, chrec2); + + tree one = build_int_cst (uns, 1); + chrec2 = fold_build2 (LSHIFT_EXPR, uns, one, chrec2); + res = chrec_fold_multiply (uns, chrec1, chrec2); + res = chrec_convert (type, res, at_stmt); + } + break; + CASE_CONVERT: /* In case we have a truncation of a widened operation that in the truncated type has undefined overflow behavior analyze |