#1845 Regression: Unsigned 16-bit comparison broken

closed-fixed
7
2011-09-14
2011-09-11
Woody
No

1. Sample code attached.
2. Command line used: C:\SDCC\BIN\sdcc dsp_bank1.c -mz80 -c --oldralloc --std-c99 --codeseg CODE1
3. SDCC version tested: SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.4 #6848 (Sep
10 2011) (MINGW32)
4. The code was compiled correct with build 6720 (as in attached dsp_bank1_6720.asm). It was correct no matter --oldalloc was used or not. And it goes wrong with build 6848 no matter --oldalloc is used or not. The bug is in sdcc.exe, put 6720 sdcc.exe into 6848 build will work correctly. By the way, the same function was compiled wrong with an earlier fixed bug report related with --max-allocs-per-node option.

Discussion

  • Woody

    Woody - 2011-09-11
     
  • Philipp Klaus Krause

    What exactly is the problem with the function?

    Does it not terminate?
    Does it pass wrong values to one of the functions it calls?
    Does it assign wrong values to a global variable?

    Philipp

     
  • Woody

    Woody - 2011-09-13

    Build 6848 had 2 obvious problems on my software, running the dsp code got dead lock and tcp was not working any more. The code here related with load dsp code from program flash to internal memory, seemed that it was not correctly done. I will try to split the code more to figure out what exactly wrong later today.

     
  • Woody

    Woody - 2011-09-13
     
  • Woody

    Woody - 2011-09-13

    I downloaded build 6849, same bug existed.
    Then I traced a smaller piece of code which generated the bug, attached in dsp_bank1_bug2.zip. dsp_bank1_correct.asm was generated by build 6720.

     
  • Philipp Klaus Krause

    '>' unsigned 16-bit comparison on is broken. It is incorrectly trasnformed into an and by sdcc from current trunk: For if(x > 0x4000) the same code as for if(x & ~0x4000) is emitted, which obviosly results in errors for e.g. x == 1.

    The problem seems to affect all ports (I tested z80 and hc08).

    Increasing priority, since broken code is silently generated.

    Philipp

     
  • Philipp Klaus Krause

    • summary: dsp_bank1.c compiled wrong again --> Regression: Unsigned 16-bit comparison broken
    • labels: 100692 -->
    • priority: 5 --> 7
     
  • Philipp Klaus Krause

    Minimal example to reproduce the bug:

    int y;

    void f(unsigned int x)
    {
    if(x > 0x4000)
    y = 0;
    }

     
  • Philipp Klaus Krause

    <= seems broken, too. I suspect (from the Changelog and svn blame, did not bisect) the following commits 6723, 6724 and 6726:

    * src/SDCCopt.c: fixed bug #3387421: Incorrect code in revision 6723,
    optimize '>' and '>=' also in case when the following instruction
    is not IFX
    * support/regression/test/compare_2_n.c:
    added test cases for bug #3387421 and for 0x0000 and 0xffff

    and

    * src/SDCCopt.c: further enhancements & fixes of patch #2702889:
    added <= and >= optimizations, optimize > only if IFX
    * support/regression/test/compare_2_n.c: added test cases without IFX

     
  • Philipp Klaus Krause

    • assigned_to: nobody --> spth
     
  • Philipp Klaus Krause

    Fixed in revision #3407632.

    Philipp

     
  • Philipp Klaus Krause

    • labels: --> Icode generator
    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Revision #6850, though I hope it will not need refixing in revision #3407632.
    Philipp

     
  • Maarten Brock

    Maarten Brock - 2011-09-14

    Can you please also add a regression test case?

     
  • Maarten Brock

    Maarten Brock - 2011-09-14

    Oops, sorry. I have misread the changelog.

     

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