Commit 46bf3f84 by Bin Cheng Committed by Bin Cheng

re PR tree-optimization/80153 (ivopt generate wrong code)

	PR tree-optimization/80153
	* tree-ssa-loop-ivopts.c (add_iv_candidate_for_use): Check and 
	remove POINTER_PLUS_EXPR's base part directly, rather than through
	aff_tree.

From-SVN: r246811
parent aac69a62
2017-04-10 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/80153
* tree-ssa-loop-ivopts.c (add_iv_candidate_for_use): Check and
remove POINTER_PLUS_EXPR's base part directly, rather than through
aff_tree.
2017-04-10 Richard Biener <rguenther@suse.de> 2017-04-10 Richard Biener <rguenther@suse.de>
Bin Cheng <bin.cheng@arm.com> Bin Cheng <bin.cheng@arm.com>
......
...@@ -3335,42 +3335,21 @@ add_iv_candidate_for_use (struct ivopts_data *data, struct iv_use *use) ...@@ -3335,42 +3335,21 @@ add_iv_candidate_for_use (struct ivopts_data *data, struct iv_use *use)
} }
/* Record common candidate with base_object removed in base. */ /* Record common candidate with base_object removed in base. */
if (iv->base_object != NULL)
{
unsigned i;
aff_tree aff_base;
tree step, base_object = iv->base_object;
base = iv->base; base = iv->base;
step = iv->step;
STRIP_NOPS (base); STRIP_NOPS (base);
STRIP_NOPS (step); if (iv->base_object != NULL && TREE_CODE (base) == POINTER_PLUS_EXPR)
STRIP_NOPS (base_object);
tree_to_aff_combination (base, TREE_TYPE (base), &aff_base);
for (i = 0; i < aff_base.n; i++)
{ {
if (aff_base.elts[i].coef != 1) tree step = iv->step;
continue;
if (operand_equal_p (aff_base.elts[i].val, base_object, 0)) STRIP_NOPS (step);
break; base = TREE_OPERAND (base, 1);
} step = fold_convert (sizetype, step);
if (i < aff_base.n)
{
aff_combination_remove_elt (&aff_base, i);
base = aff_combination_to_tree (&aff_base);
basetype = TREE_TYPE (base);
if (POINTER_TYPE_P (basetype))
basetype = sizetype;
step = fold_convert (basetype, step);
record_common_cand (data, base, step, use); record_common_cand (data, base, step, use);
/* Also record common candidate with offset stripped. */ /* Also record common candidate with offset stripped. */
base = strip_offset (base, &offset); base = strip_offset (base, &offset);
if (offset) if (offset)
record_common_cand (data, base, step, use); record_common_cand (data, base, step, use);
} }
}
/* At last, add auto-incremental candidates. Make such variables /* At last, add auto-incremental candidates. Make such variables
important since other iv uses with same base object may be based important since other iv uses with same base object may be based
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment