This is the mail archive of the gcc-patches@gcc.gnu.org mailing 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]

Re: [Committed] PR middle-end/18548: RTL expansion of MAX_EXPR


On Saturday 18 December 2004 14:12, Roger Sayle wrote:
> This patch resolves PR middle-end/18548 which is a wrong-code regression
> on mainline.  The problem is that the RTL sequences generated for MIN_EXPR
> and MAX_EXPR generated can clobber "target" which may still be required
> to evaluate op0 and/or op1.

Heh, you beat me to it :-)


> 	PR middle-end/18548
> 	* expr.c (expand_expr_real_1) <MAX_EXPR>: Ensure that target, op0
> 	and op1 are all registers (or constants) before expanding the RTL
> 	comparison sequence [to avoid reg_overlap_mentioned (target, op1)].
>
> 	* gcc.dg/max-1.c: New test case.

So, what if the optab requires target for op0 and op1?  There is still this:

      /* First try to do it with a special MIN or MAX instruction.
         If that does not win, use a conditional jump to select the proper
         value.  */
      this_optab = optab_for_tree_code (code, type);
      temp = expand_binop (mode, this_optab, op0, op1, target, unsignedp,
                           OPTAB_WIDEN);

and with your patch we force op1 into a reg _after_ this code.  Shouldn't
expand_binop be allowed to assume we've already handled any evaluation
hazards?

Gr.
Steven


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