This is similar to the discussion that happened some time ago about
extending return values. The decisions for that was that the callee
could just leave the higher bits undefined and the caller would
extent the result if it needed to.

We have a similar issue with function arguments. We compile

void g(short);

void f(short a) {
  g(a);
}

into

f:
.LFB2:
        movswl  %di,%edi
        jmp     g

we should really be able to remove the movswl. If the caller
is required to do sign extension, who called f has
extended the argument already. If the callee is required,
then g will do it and there is no need for f to do it.

What is more interesting is the case

void g(int);

void f(short a) {
  g(a);
}

Can f assume that its caller did a sign extension or
it is its responsibility to extend A?

Cheers,
-- 
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047

Reply via email to