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: [PATCH] Prefer reg as first operand in commutative operator


On 02/14/2012 10:52 AM, Jakub Jelinek wrote:
>        /* Complex expressions should be the first, so decrease priority
>           of objects.  Prefer pointer objects over non pointer objects.  */
> -      if ((REG_P (op) && REG_POINTER (op))
> -	  || (MEM_P (op) && MEM_POINTER (op)))
> -	return -1;
> -      return -2;
> +      if(REG_P(op))
> +          return -1;
> +      else if ((REG_P (op) && REG_POINTER (op))
> +               || (MEM_P (op) && MEM_POINTER (op)))
> +          return -2;
> +      return -3;
The above is definitely wrong, I think it will penalize e.g. Power6/7 a lot.

Even if this was fixed, I'm not sure it is always the correct thing to do, because it would override swap_commutative_operands_with_target. If the target is memory, you'd want the memory to come first.


In other words, there is no right answer as to whether REG or MEM should come first.

I think the register allocator will generate good code using % if you make your predicate nonimmediate_operand in operand 1:

(define_insn "iorqi3"
  [(set (match_operand:QI 0 "register_operand" "=c")
        (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
                (match_operand:QI 2 "general_operand" "cwmi")))
   (clobber (reg:CC RCC))]
  "register_operand(operands[1], QImode) ||
   register_operand(operands[2], QImode)"
  "or\\t%0,%f2")

Paolo


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