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]

Re: code quality pesimization with function returning changes


On Tue, Jun 05, 2001 at 05:50:44PM +0200, Jan Hubicka wrote:
> (insn 25 23 26 (clobber (reg/i:SI 0 eax)) -1 (nil)
>     (nil))
> 
> (insn 28 26 29 (set (reg/i:SI 0 eax)
>         (reg:SI 58)) -1 (nil)
>     (nil))
> 
> See the insn 28, that sets eax according to the reg 58.  The reg 58 is
> never set, so it is live over whole function body.  This prevents
> tail call optimization and pesimizes register allocation.

We should have reg 58 clobbered at the same time as EAX here,
I think.  See clobber_return_register; change it to notice the
return value in a pseudo.

> What exactly the patch solves?

Stuff like

	if (p)
	  return a + b;
	else
	  return c + d;

can get translated as

	(set pc (if_then_else p pc (label 1)))

	(set (reg:SI tmp) (plus:SI a b))

	(set (reg:DI r0) (sign_extend:DI (reg:SI tmp)))

	(set pc (label 2))

	(code_label 1)

	(set (reg:SI tmp2) (plus:SI c d))

	(set (reg:DI r0) (sign_extend:DI (reg:SI tmp2)))

	(code_label 2)

Before we had cant_combine_p, we'd happily collapse the PLUS and the
SIGN_EXTEND into a single instruction.  Now, we see R0 and prevent the
combination.  Which in turn prevents noce_try_cmove_arith from building

	(set (reg:DI tmp) (sign_extend:DI (plus:SI a b)))

	(set (reg:DI r0) (sign_extend:DI (plus:SI c d)))

	(set (reg:DI r0) (if_then_else:DI p tmp r0))

With the return value in a pseudo, we don't have this problem.


r~


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