This is the mail archive of the gcc-help@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: double argument casting


laurent <laurent.poche@gmail.com> writes:

> When a caller function calls a callee function with short or char
> arguments, the arguments are casted twice: inside the caller function
> and inside the callee function, see the example. It is a waste of
> performance in code density and speed!
>
> I don't understand why there is a double casting.  Is there any
> optimization I could activate in GCC to remove it?

It's basically a bug.  gcc should only do it on the caller side.  Doing
it on the callee side is a holdover from the good pre-C90 days, when
code like

int f(i)
    char i;
{
  ...
}

had to be treated as equivalent to

int f(int passed_i)
{
  char i = (char) passed_i;
  ...
}

These days I think we can just drop the cast on the callee side.  As I
recall that was done for x86 a while back, somebody just needs to do it
for SPARC.

Please file a bug report according to the instructions at
http://gcc.gnu.org/bugs/ (unless there is already a bug report for
this).  Thanks.

Ian


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