This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, mips] Fix optimization bug involving nor instruction
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Steve Ellcey <sellcey at mips dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 22 Oct 2013 19:12:47 +0100
- Subject: Re: [patch, mips] Fix optimization bug involving nor instruction
- Authentication-results: sourceware.org; auth=none
- References: <5bfd0151-01e6-4f25-bcc6-0a0f7bb4d56b at BAMAIL02 dot ba dot imgtec dot org> <87ob6hcir1 dot fsf at sandifor-thinkpad dot stglab dot manchester dot uk dot ibm dot com> <1382463841 dot 2558 dot 75 dot camel at ubuntu-sellcey>
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