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, mips] Fix optimization bug involving nor instruction


Steve Ellcey <sellcey@mips.com> writes:
> On Tue, 2013-10-22 at 18:34 +0100, Richard Sandiford wrote:
>> Good spot!
>
>> We should use set_src_cost for both operands (the idea being that only
>> a register is allowed, and that anything else will end up being a SET_SRC).
>> I think the formatting should be something like:
>> 
>>       /* (AND (NOT op0) (NOT op1)) is a NOR operation that can be done in
>> 	 a single instruction.  */
>>       if (!TARGET_MIPS16
>> 	  && GET_CODE (XEXP (x, 0)) == NOT
>> 	  && GET_CODE (XEXP (x, 1)) == NOT)
>> 	{
>> 	  cost = GET_MODE_SIZE (mode) > UNITS_PER_WORD ? 2 : 1;
>> 	  *total = (COSTS_N_INSNS (cost)
>> 		    + set_src_cost (XEXP (XEXP (x, 0), 0), speed)
>> 		    + set_src_cost (XEXP (XEXP (x, 1), 0), speed));
>> 	  return true;
>> 	}
>> 
>> OK with that change, thanks.
>> 
>> Richard
>
> OK, but I am curious why you put parenthesis around the right hand side
> of the total expression.  I.e.  *total = (....);

That's the "emacs formatting" rule:

  Insert extra parentheses so that Emacs will indent the code
  properly. For example, the following indentation looks nice if you do
  it by hand,

  v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
      + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;

  but Emacs would alter it. Adding a set of parentheses produces
  something that looks equally nice, and which Emacs will preserve:

  v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
       + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);

Thanks,
Richard


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