Menu

#486 sdcc: msc51 port insert unused instruction when inline is combined with boolean types

None
open
nobody
None
5
2016-02-01
2016-01-28
No

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

Discussion

  • Peter Dons Tychsen

    Just to clarify, the instruction are of course "used", but execution of it is a no-op.

     
  • Peter Dons Tychsen

    If the inline keyword is not used the bug vanishes.

     
  • Maarten Brock

    Maarten Brock - 2016-01-30

    Ticket moved from /p/sdcc/bugs/2465/

    Can't be converted:

    • _category: other
     
  • Maarten Brock

    Maarten Brock - 2016-01-30

    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.

     
  • Peter Dons Tychsen

    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

     

Log in to post a comment.