Altera_Forum
Honored Contributor
21 years agoUnnecessary instructions
Hello, it's my first post.
I have question about GCC generated code. We can find several unnecessary instructions. --- sample code --- unsigned short uh; uh = IORD_16DIRECT(base,ofst); printf("",uh); --- GCC generated (part) --- ldhuio r18,0(r16) andi r20, r18, 65535 * call printf "ldhuio" instruction is zero-extending load, so r18 is already zero-extended. Next "andi" is unnecessary. Here is another sample. --- sample code --- short sh; sh = __builtin_ldhio(base); printf("",sh); --- GCC generated (part) --- ldhio r17, 0(r16) slli r7, r17, 16 * srai r21, r7, 16 * call printf Also, "ldhio" is signed-extending load, so r17 is already signed-extended. Next 2 shifts are waste. Does anyone have ideas to eliminate these unnecessary instructions? Regards, marm