This is the mail archive of the gcc@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: PowerPC suboptimal "add with carry" optimization


Joakim Tjernlund <joakim.tjernlund@transmode.se> writes:

> Ian Lance Taylor <iant@google.com> wrote on 2010/04/25 20:07:03:
>>
>> Joakim Tjernlund <joakim.tjernlund@transmode.se> writes:
>>
>> > Noticed that gcc 4.3.4 doesn't optimize "add with carry" properly:
>
> BTW, I can see in gcc src:
> (define_insn ""
>   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
> 	(compare:CC
> 	 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
> 			 (const_int 0))
> 		  (match_operand:SI 2 "gpc_reg_operand" "r,r"))
> 	 (const_int 0)))
>    (clobber (match_scratch:SI 3 "=&r,&r"))]
>   "TARGET_32BIT"
>   "@
>    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
>    #"
>   [(set_attr "type" "compare")
>    (set_attr "length" "12,16")])
> so there seems to be possible for gcc to emit them but how do
> I make gcc do that?

That unfortunately does not do what you want.  That instruction
sequence uses a scratch register to set a condition register to
whether (a + b) > 0.

Ian


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