Hello SDCC team,
While working on: https://sourceforge.net/p/sdcc/bugs/2458,
i found this one, which i thought was related to my patch, but it seems like its just a general bug.
code
#include <stdio.h> #include <stdbool.h> inline bool func (int c) { return (c+1); } char c; void test (void) { if(func(++c)) { while(1); } }
When compiled, it spits out unused instructions that puts things in the bit area like:
mov _test___00010001_4_26,c
Which are never used.
Thanks,
/pedro
Just to clarify, the instruction are of course "used", but execution of it is a no-op.
If the inline keyword is not used the bug vanishes.
Ticket moved from /p/sdcc/bugs/2465/
Can't be converted:
Inefficient code is not considered a bug. This is at best a feature request for better optimization.
This behaviour is due to the use of an intermediate temporary _test___00010001_4_26 which is then later partially optimized by the peephole optimizer. The peepholer sees a more efficient way to get the temporary but has no way to find out if this was the only use and thus cannot remove the store as well.
OK Maarten,
Thanks for checking it out. I just wanted to make sure this got filed in some manor, as the fix for bug #2458 exposed this futher.
Thanks,
/pedro