Ok, since now, I'm out for next two days.
Any bug, if found, will be fixed on friday :)
~d

On Tuesday 15 July 2003 18:05, Dmitry wrote:
> fixed.
> the code is in cvs.
>
> The idea is:
> when jump being performed upon comparison of some variable against zero and
> r2 set by the previous arithmetic instruction, for one and two byte
> operands forget about overflow:
> if operation is '<', then check only negative flag.
> when operation is '>=' clear overflow first, then perform 'jge'
>
> ~d
>
> P.S. Steve, please rebuild windoze distrs. Thanks.
>
> On Tuesday 15 July 2003 03:51, Takahashi, Chris wrote:
> > I have discovered code which optimizes improperly.  Attached are multiple
> > versions of the code.  The code is incorrect if any level of optimization
> > is on (-O1 -O2 -O3 or -Os).  test.c is compileable under gcc and
> > msp430-gcc. When targeted at i386 the source generates valid code with
> > both -D_WORK_ (the _WORK_ define switches from a valid to invalid version
> > when compiled) and with out (in fact it creates the same code).  Also
> > attached is math.c which contains the problematic code with minimal
> > support code so that a minimal object can be created.  math.c also is the
> > same as the preprocessed code of math.c.
> >
> > When compiled for the MSP target it uses msp430 simulator to assess the
> > validity of the code.  When the dysfunctional code is compiled it creates
> > a jl instruction in place of a jn instruction after the if statement (see
> > attached math.lst).
> >
> > I have included a make file to make viewing the bug easier.  All you need
> > is the simulator in your path and it will make the code and run the test
> > cases.
> >
> > About the code:
> > The attached code (in math.c) increments the upper nibble of temp1 by 3
> > then
> >
> > examines the upper nibble of temp1 to see if it is >= 8.  If it is then
> > do nothing, otherwise
> > undo the increment by decrementing the upper nibble by 3.
> >
> > The assembly generated performs the inc by 3 then checks the n and v
> > flags with the jl instruction to determine when to jump.  because only
> > the last bit is being checked it is only appropriate to check the n flag
> > -- as the result of the last arithmetic instr is inconsequential (aside
> > from the content of bit 7).
> >
> > If any more info is needed please mail me or the list.  And I'll send it
> > ASAP.
> >
> > -Chris Takahashi

-- 
/*****************************************************************
     ("`-''-/").___..--''"`-._     (\   Dimmy the Wild     UA1ACZ
      `6_ 6  )   `-.  (     ).`-.__.`)  State Polytechnical Univ.
      (_Y_.)'  ._   )  `._ `. ``-..-'   Radio-Physics Departament
    _..`--'_..-_/  /--'_.' ,'           Saint Petersburg,  Russia
   (il),-''  (li),'  ((!.-'             +7 (812) 5403923, 5585314
 *****************************************************************/


Reply via email to