This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Strange RTL problem
On Wed, May 01, 2002 at 02:47:54PM -0500, Chris Lattner wrote:
>
> I'm having a really wierd problem with a backend that I'm working on for
> the following C code snippet:
>
> int printf(const char *, ...);
> int main() {
> signed char c0 = -1;
> unsigned char c1 = 255;
> printf("bs0 = %d %d\n", c0, c1);
> return 0;
> }
>
> I'd like to see output of -1, 255, but my target is generating "255 255".
>
> Looking at the RTL, I see these two INSNs:
>
> (insn 23 21 25 (set (mem/f:QI (plus:PDI (reg/f:PDI 14 %sp)
> (const_int 8 [0x8])) 0)
> (const_int -1 [0xffffffff])) 9 {*movqi} (nil)
> (nil))
>
> (insn 25 23 26 (set (mem/f:QI (plus:PDI (reg/f:PDI 14 %sp)
> (const_int 12 [0xc])) 0)
> (const_int 255 [0xff])) 9 {*movqi} (nil)
> (nil))
>
> which are immediately before the printf call. Since both arguments are 8
> bit quantities, they are stored onto the stack as QI mode, but doing
> so they lose the integral promotion that would make them signed or
> unsigned (this only happens with vararg functions).
It sounds like you're actually pushing them onto stack as QImode?
That's wrong for at least C; they should be promoted to int (presumably
SImode) before they are pushed.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer