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] Rename/export combine_insn_cost as insn_rtx_cost


Roger Sayle <roger@eyesopen.com> writes:

> On Fri, 16 Jul 2004, Zack Weinberg wrote:
>> Unfortunately, p6 *is* call-clobbered on ia64.
>
> I've just thought of an even cleverer work-around.
>
> Instead we transform
>
> 	if (cond)
> 	{
> 	  call foo();
> 	  r1 = r35;
> 	}
>
> into the equivalent.
>
> 	if (cond)
> 	  call foo ();
> 	else
> 	  r35 = r1;
> 	r1 = r35;
>
> which we'd expand as
>
> 	(!cond).r35 = r1
> 	(cond).call foo()
> 	r1 = r35
>
> i.e. we attempt to compensate for any instructions after a conditional
> instruction that clobbers the condition codes, by inserting additional
> code in the else clause (using the negated/inverted conditional earlier).

Cute.

In this example, there's not even need to use the else - r35 is the
register where r1 was saved on function entry, and an extra copy from
r35 to r1 is harmless.  So we could emit something like

      cmp4.ne.unc p6,p7 = r0,r32
 (p6) br.call.dpnt.many b0 = foo#
      ;;
      mov  r1 = r35

with complete safety.  Your trick, however, might be better for cases
where there's more code after the call.

zw


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