[BUG REPORT OPTIMISER]

wrong address calculaction

  • 1
  • 2
  • Page 2 of 2
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: [BUG REPORT OPTIMISER]

 · 
Posted: 25.01.2016 - 22:19  ·  #9
@all

The problems are a little more subtle than it would at first appear. The particular implementation has some fairly obvious solutions, as you say with ADIW, but that would be a totally new optimisation. This is actually a manifestation of a deeper problem, which I need to think about first. My main concern is that fixing this problem may introduce new ones.

Once I have solved this problem to my satisfaction I will look at implementing the ADW/SBIW, probably as a separate release.
Harald_K
 
Avatar
 
Subject:

Re: [BUG REPORT OPTIMISER]

 · 
Posted: 25.01.2016 - 22:35  ·  #10
or you use
LDI _ACCA, xx
STS Z, _ACCA
LDI _ACCA, yy
STD Z+11, _ACCA
LDI _ACCA, ...
STD Z+22, ...

which will use only 2 cycles for adding and storing instead of 3 for adding separately and storing ... it also will use smaller amount of ROM,
but the displacement is only +/-63 and the Z-Register is not changed ... the flags are not changed too

all depends on the number and size of displacements to add ... so you must decide what to do ...
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: [BUG REPORT OPTIMISER]

 · 
Posted: 26.01.2016 - 15:01  ·  #11
Hello Merlin,

an easy solution which the Opti should be able to handle is this:
original ASM
Code
  LDI       _ACCCLO, optimizerAddressBug.btnArray AND 0FFh
  LDI       _ACCCHI, optimizerAddressBug.btnArray SHRB 8
  ADIW      _ACCCLO, 0000Bh
  LDI       _ACCA, 002h
  ST        Z+, _ACCA 

Optimiser
Code
  LDI       _ACCCLO, optimizerAddressBug.btnArray+11 AND 0FFh
  LDI       _ACCCHI, optimizerAddressBug.btnArray+11 SHRB 8
  LDI       _ACCA, 002h
  ST        Z+, _ACCA

The offset, in this case 11/$0B, is directly added into the Z-pointer load

rolf
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: [BUG REPORT OPTIMISER]

 · 
Posted: 26.01.2016 - 22:20  ·  #12
@All

I sincerely thank you all for your input, I truly do, but the problem is not the one that you imagine.

The problem is that the optimiser interprets addresses wrongly, and therefore incorrectly optimises. Sadly, the solutions that you propose only mask the problem, not solve it. Now the problem is correctly solved, the original optimisation is almost as efficient your proposed solutions, and so it is not worth adding a new optimisation, especially as it only solves a very limited problem that would not be used in practice (a for loop would be used instead typically).

Thomas, do you need me to e-mail you with the fix? If so, please let me know your e-mail by pm.

Thank you all again.

@Rolf: Your last suggestion is exactly what the optimiser does. The problem is that a later optimisation removes what it sees as superfluous lines, which are mostly correct, but not quite all.
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: [BUG REPORT OPTIMISER]

 · 
Posted: 27.01.2016 - 11:59  ·  #13
Hello again,

@all: Thanks for your Input, too.
@Merlin: Not neccessary, I am waiting for an official update.
  • 1
  • 2
  • Page 2 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   93   107 · Page-Gen-Time: 0.02768s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI