[backport proposed 4.8 fix for emit_conditional_add ] Date: Fri, 24 Aug 2012 15:43:39 -0700 Subject: Re: [PATCH] Fix emit_conditional_add and documentation for add@var{mode}cc From: Andrew Pinski List-Archive: Forgot to attach the patch. -- Andrew On Fri, Aug 24, 2012 at 3:42 PM, Andrew Pinski wrote: > Hi, > I decided to split this patch from the other patch which uses > emit_conditional_add in expand as that part of the patch needs some > work. This part of the patch can be applied separately and it fixes a > few things dealing with conditional adds. > > First the documentation is wrong for the pattern as we do the addition > if operand 0 is true rather than false. > Then emit_conditional_add is wrong as you cannot switch around op2 and op3. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > Thanks, > Andrew Pinski > > ChangeLog: > * optabs.c (emit_conditional_add): Correct comment about the arguments. > Remove code which might swap op2 and op3 since they cannot be swapped. > * doc/md.texi (add@var{mode}cc): Fix document about how the arguments are used. --- gcc-4.6.3/gcc/doc/md.texi.~1~ 2011-08-12 18:29:29.000000000 +0200 +++ gcc-4.6.3/gcc/doc/md.texi 2012-09-01 14:26:22.000000000 +0200 @@ -4830,7 +4830,7 @@ define these patterns. @item @samp{add@var{mode}cc} Similar to @samp{mov@var{mode}cc} but for conditional addition. Conditionally move operand 2 or (operands 2 + operand 3) into operand 0 according to the -comparison in operand 1. If the comparison is true, operand 2 is moved into +comparison in operand 1. If the comparison is false, operand 2 is moved into operand 0, otherwise (operand 2 + operand 3) is moved. @cindex @code{cstore@var{mode}4} instruction pattern --- gcc-4.6.3/gcc/optabs.c.~1~ 2011-03-04 11:27:10.000000000 +0100 +++ gcc-4.6.3/gcc/optabs.c 2012-09-01 14:26:22.000000000 +0200 @@ -4577,7 +4577,7 @@ can_conditionally_move_p (enum machine_m the mode to use should they be constants. If it is VOIDmode, they cannot both be constants. - OP2 should be stored in TARGET if the comparison is true, otherwise OP2+OP3 + OP2 should be stored in TARGET if the comparison is false, otherwise OP2+OP3 should be stored there. MODE is the mode to use should they be constants. If it is VOIDmode, they cannot both be constants. @@ -4591,7 +4591,6 @@ emit_conditional_add (rtx target, enum r { rtx tem, subtarget, comparison, insn; enum insn_code icode; - enum rtx_code reversed; /* If one operand is constant, make it the second one. Only do this if the other operand is not constant as well. */ @@ -4615,16 +4614,6 @@ emit_conditional_add (rtx target, enum r if (cmode == VOIDmode) cmode = GET_MODE (op0); - if (swap_commutative_operands_p (op2, op3) - && ((reversed = reversed_comparison_code_parts (code, op0, op1, NULL)) - != UNKNOWN)) - { - tem = op2; - op2 = op3; - op3 = tem; - code = reversed; - } - if (mode == VOIDmode) mode = GET_MODE (op2);