[PATCH] Improve # of iterations analysis, fix PR26900
Richard Guenther
rguenther@suse.de
Thu Mar 30 13:01:00 GMT 2006
On Thu, 30 Mar 2006, Diego Novillo wrote:
> On 03/30/06 04:11, Richard Guenther wrote:
>
> > + static tree
> > + compare_conditions (tree cond1, tree cond2)
> > + {
> >
> Need comment explaining what we are doing here. It's not immediately
> obvious.
Whoops - completely forgot about that.
/* Given two comparisons COND1 and COND2 figure out if either
COND2 is always true if COND1 is true or if COND2 is always false
if COND1 is true. Returns boolean_true_node in the first case,
boolean_false_node in the second one and NULL_TREE, if we cannot
prove either of the relations. */
> > + /* Canonicalize to (possibly) the same SSA_NAME on the lhs of both
> > + conditions. */
> > + if (!operand_equal_p (lhs1, lhs2, 0))
> >
> You can do direct comparisons with SSA names.
Ok, fixed. Likewise below for the lhs comparison.
> > + {
> > + cond2 = fold_build2 (swap_tree_comparison (TREE_CODE (cond2)),
> > + boolean_type_node, rhs2,
> > + build2 (PLUS_EXPR, TREE_TYPE (lhs2),
> > + lhs2, build_int_cst (TREE_TYPE (lhs2), 0)));
> > + lhs2 = TREE_OPERAND (cond2, 0);
> > + rhs2 = TREE_OPERAND (cond2, 1);
> > + }
> > +
> > + /* Verify that now both lhs and rhs are equal. */
> > + if (!operand_equal_p (lhs1, lhs2, 0)
> > + || !operand_equal_p (rhs1, rhs2, 0))
> > + return NULL_TREE;
> > +
> > + /* Same condition, cond2 follows from cond1. */
> >
> You'll need to be a bit more detailed in what you mean with 'cond2
> follows from cond1'. The comment at the start of the function should
> include this reasoning.
I'll change to /* Same condition, cond2 is true if cond1 is. */
Ok with these changes?
Thanks,
Richard.
More information about the Gcc-patches
mailing list