#115 PIC16: fix genUminus - addresses not.c regression test


Hello everybody,
the attached patch fixes the PIC16's genUminus bug that causes the
not.c regression test failures.

The not.c tests fail to compile (compiler assertion) when
{attr}==volatile. The problem resulted to be neither related to the
"!" operator nor to volatile itself.

The smallest failing testcase I could write down is:
#include <testfwk.h>
unsigned char volatile ucv;
unsigned char uc;
ucv = 0;
uc = ucv;
ucv = (uc * -1 < 0);

The problem is that CSE replaces "uc * -1" with "-uc", so that the
tree contains an UNARYMINUS node with the operand and the result
differently sized. PIC16's genUminus couldn't cope with that and the
assertion failed.
From my POV there are 2 ways to fix this: in SDCCcse.c adding a cast
node in the tree, or in genUminus adding the code to handle that case.
Since the problem appeared PIC16-specific and adding a cast could
throw away possible optimizations, I went for the second and fixed

The patch effect is almost a plain NOP for the case where the operand
and the result are of the same size, so I don't expect this to cause

With best regards

PS: I'll be on vacation/away till about the first week of September,
and I most probably won't reply to mails in that timeframe.
Sorry about that. I'll read mail and reply as soon as I'm back.


  • Mauro Giachero

    Mauro Giachero - 2008-08-12

    Patch fixing PIC16's genUminus bug

  • Borut Ražem

    Borut Ražem - 2008-08-23
    • assigned_to: nobody --> borutr
    • status: open --> closed-accepted
  • Borut Ražem

    Borut Ražem - 2008-08-23

    Logged In: YES
    Originator: NO

    Patch applied in svn revision #5218.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks