Why does gcc produce an unnecessary `nop' instruction?

Ian Lance Taylor iant@google.com
Fri Jan 25 22:55:00 GMT 2008


"PRC" <panruochen@gmail.com> writes:

> The assembly code produced by gcc is:
> -----------------------------------------------
> 800650b0 <loadicon>:
> 800650b0:	3c048006 	lui	a0,0x8006
> 800650b4:	0801964b 	j	8006592c <SetBufAddr>
> 800650b8:	24846128 	addiu	a0,a0,24872
> 800650bc:	00000000 	nop
> -----------------------------------------------
> The `nop' instruction seems useless at all here.

It's probably caused by requested alignment of the next function.
Note that nop is just the value 0.

To see whether gcc is actually generating the nop, use the
--save-temps option when you compile, and look at the .s file.  If you
don't see the nop there, it's coming from something other than gcc.

Ian



More information about the Gcc-help mailing list