Skip to content

Peephole does not care about autoincrement #478

@spotlessmind1975

Description

@spotlessmind1975

In some algorithms it is possible to carry out the so-called "loop unrolling", that is to avoid introducing a loop by making the operations explicit for a certain number of times.

For example, instead of writing like this:

      LDB 4
  L1
      LDA ,U
      STA ,Y
      LEAU 1, U
      LEAY 1, Y
      DECB
      BNE L1

can be written like this:

    LDA ,U+
    STA ,Y+
    LDA ,U+
    STA ,Y+
    LDA ,U+
    STA ,Y+
    LDA ,U+
    STA ,Y+

However, the current optimizer does not recognize that we are in the presence of an automatic increment and this implies the following (incorrect) optimization:

	LDA ,U+
; peephole(3): r620 (STORE*,STORE*)->(STORE*)
;	STA ,Y+
; peephole(1): r586 (LOAD*,STORE,LOAD*)->(LOAD*,STORE)
;    LDA ,U+
; peephole(1): r608 (STORE*,LOAD,STORE*)->(LOAD,STORE*)
;    STA ,Y+
; peephole(2): r586 (LOAD*,STORE,LOAD*)->(LOAD*,STORE)
;	LDA ,U+
; peephole(2): r620 (STORE*,STORE*)->(STORE*)
;	STA ,Y+
; peephole(1): r586 (LOAD*,STORE,LOAD*)->(LOAD*,STORE)
;    LDA ,U+
	STA ,Y+

Metadata

Metadata

Assignees

No one assigned

    Labels

    6809Motorola 6809bugSomething isn't workingoptimizationOptimization

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions