aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-pre.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-01-15 15:02:11 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-01-15 15:02:11 +0000
commit42c6b3cadd77829763b2a1484c5cfa50a9524b1f (patch)
tree52b26abff657f8b34fcdc7839ec71998826959cc /gcc/tree-ssa-pre.c
parentcd3246ea5820971a463d8d46d94ddd7128ab0282 (diff)
downloadgcc-42c6b3cadd77829763b2a1484c5cfa50a9524b1f.zip
gcc-42c6b3cadd77829763b2a1484c5cfa50a9524b1f.tar.gz
gcc-42c6b3cadd77829763b2a1484c5cfa50a9524b1f.tar.bz2
re PR tree-optimization/61743 (Complete unroll is not happened for loops with short upper bound)
2015-01-15 Richard Biener <rguenther@suse.de> PR tree-optimization/61743 * tree-ssa-pre.c (insert_into_preds_of_block): Preserve range information on PHIs for some simple cases. * gcc.dg/tree-ssa/pr61743-1.c: New testcase. * gcc.dg/tree-ssa/pr61743-2.c: Likewise. From-SVN: r219662
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r--gcc/tree-ssa-pre.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 3ef7510..32cd74d 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3184,6 +3184,33 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
bitmap_insert_into_set (NEW_SETS (block),
newphi);
+ /* If we insert a PHI node for a conversion of another PHI node
+ in the same basic-block try to preserve range information.
+ This is important so that followup loop passes receive optimal
+ number of iteration analysis results. See PR61743. */
+ if (expr->kind == NARY
+ && CONVERT_EXPR_CODE_P (expr->u.nary->opcode)
+ && TREE_CODE (expr->u.nary->op[0]) == SSA_NAME
+ && gimple_bb (SSA_NAME_DEF_STMT (expr->u.nary->op[0])) == block
+ && INTEGRAL_TYPE_P (type)
+ && INTEGRAL_TYPE_P (TREE_TYPE (expr->u.nary->op[0]))
+ && (TYPE_PRECISION (type)
+ >= TYPE_PRECISION (TREE_TYPE (expr->u.nary->op[0])))
+ && SSA_NAME_RANGE_INFO (expr->u.nary->op[0]))
+ {
+ wide_int min, max;
+ if (get_range_info (expr->u.nary->op[0], &min, &max) == VR_RANGE
+ && !wi::neg_p (min, SIGNED)
+ && !wi::neg_p (max, SIGNED))
+ /* Just handle extension and sign-changes of all-positive ranges. */
+ set_range_info (temp,
+ SSA_NAME_RANGE_TYPE (expr->u.nary->op[0]),
+ wide_int_storage::from (min, TYPE_PRECISION (type),
+ TYPE_SIGN (type)),
+ wide_int_storage::from (max, TYPE_PRECISION (type),
+ TYPE_SIGN (type)));
+ }
+
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Created phi ");