[4.1/4.0/3.4] fix pr19672 by tuning expansion of TRUTH_{AND,OR}_EXPR

Eric Botcazou ebotcazou@adacore.com
Thu Oct 20 17:01:00 GMT 2005


> This patch fixes pr19672 (pessimized code for a loop whose condition has
> && or ||) by adding a special-cased expansion of TRUTH_AND_EXPR and
> TRUTH_OR_EXPR in do_jump.
>
> Like COND_EXPR or NE_EXPR, it makes sense to have a special expansion so
> that
>
>    if (a || b) goto xy;
>
> can be translated to
>
>    if (a) goto xy;
>    if (b) goto xy;

Hum...

/* ANDIF and ORIF allow the second operand not to be computed if the
   value of the expression is determined from the first operand.  AND,
   OR, and XOR always compute the second operand whether its value is
   needed or not (for side effects).  The operand may have
   BOOLEAN_TYPE or INTEGER_TYPE.  In either case, the argument will be
   either zero or one.  For example, a TRUTH_NOT_EXPR will never have
   an INTEGER_TYPE VAR_DECL as its argument; instead, a NE_EXPR will be
   used to compare the VAR_DECL to zero, thereby obtaining a node with
   value zero or one.  */
DEFTREECODE (TRUTH_ANDIF_EXPR, "truth_andif_expr", 'e', 2)
DEFTREECODE (TRUTH_ORIF_EXPR, "truth_orif_expr", 'e', 2)
DEFTREECODE (TRUTH_AND_EXPR, "truth_and_expr", 'e', 2)
DEFTREECODE (TRUTH_OR_EXPR, "truth_or_expr", 'e', 2)
DEFTREECODE (TRUTH_XOR_EXPR, "truth_xor_expr", 'e', 2)
DEFTREECODE (TRUTH_NOT_EXPR, "truth_not_expr", 'e', 1)

Ada is badly broken, please revert.

Thanks in advance.

-- 
Eric Botcazou



More information about the Gcc-patches mailing list