Richard Guenther - Re: [patch] for PR 26900 (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

On Fri, 16 Feb 2007, Zdenek Dvorak wrote:

Hello,

Btw, I bootstrapped and tested the following patch on top of yours on x86_64-unknown-linux-gnu.

do you have some testcase where this is useful? I guess it can avoid need to use invert_truthvalue in some cases.

I just restructured the code moving the invert_truthvalue case last and adding additional allowed return values (folding a && b to a or !a || b to !a allows us to derive a value for b, too, not only true and false folding results).

No, I didn't search for a testcase.

Richard.

Zdenek

Richard.

Index: tree-ssa-loop-niter.c

*** tree-ssa-loop-niter.c (revision 122036) --- tree-ssa-loop-niter.c (working copy) *************** tree_simplify_using_condition_1 (tree co *** 832,852 ****

te = expand_simple_operations (expr);

! /* Check whether COND ==> EXPR. / notcond = invert_truthvalue (cond); e = fold_binary (TRUTH_OR_EXPR, boolean_type_node, notcond, te); if (e && integer_nonzerop (e)) return e; ! ! / Check whether COND ==> not EXPR. */ ! e = fold_binary (TRUTH_AND_EXPR, boolean_type_node, cond, te); ! if (e && integer_zerop (e)) ! return e;

return expr;

}

! /* Tries to simplify EXPR using the condition COND. Returns the simplified expression (or EXPR unchanged, if no simplification was possible). Wrapper around tree_simplify_using_condition_1 that ensures that chains of simple operations in definitions of ssa names in COND are expanded, --- 833,860 ----

te = expand_simple_operations (expr);

! e = fold_binary (TRUTH_AND_EXPR, boolean_type_node, cond, te); ! /* If COND && EXPR is false, EXPR is false. / ! if (e && integer_zerop (e)) ! return e; ! / If COND && EXPR is equal to COND or true, EXPR is true. */ ! if (e && (e == cond || integer_nonzerop (e))) ! return boolean_true_node; ! notcond = invert_truthvalue (cond); e = fold_binary (TRUTH_OR_EXPR, boolean_type_node, notcond, te);

  • /* If !COND || EXPR is true then EXPR is true. / if (e && integer_nonzerop (e)) return e; ! / If !COND || EXPR is equal to !COND or false then EXPR is false. */ ! if (e && (e == notcond || integer_zerop (e))) ! return boolean_false_node;

    return expr;

}

! /* Tries to simplify EXPR using the condition COND which is known to ! evaluate to true at the point EXPR is evaluated. Returns the simplified expression (or EXPR unchanged, if no simplification was possible). Wrapper around tree_simplify_using_condition_1 that ensures that chains of simple operations in definitions of ssa names in COND are expanded,

-- Richard Guenther rguenther@suse.de Novell / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]