Branch: Tag:

2014-12-04

2014-12-04 19:23:08 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Peep: Fixed some dead peep hole optimizer rules.

Some rules were not executed due to the matching pattern containing segments
that were fully matched by other patterns.

An example from the instant case (simplified):

NUMBER ASSIGN_LOCAL_AND_POP: ASSIGN_LOCAL_NUMBER_AND_POP
MARK NUMBER ASSIGN_LOCAL_AND_POP: NUMBER ASSIGN_LOCAL_AND_POP MARK

The second pattern will never match, since the suffix will be replaced by
the first rule. This patch fixes it by rewriting the second rule by hand:

MARK ASSIGN_LOCAL_NUMBER_AND_POP: ASSIGN_LOCAL_NUMBER_AND_POP MARK

A proper fix would be to have mkpeep.pike calculating the transitive closure.

665:      // Move marks to where they're relevant.   MARK CLEAR_LOCAL: CLEAR_LOCAL($2a) MARK - MARK NUMBER ASSIGN_LOCAL_AND_POP: NUMBER($2a) ASSIGN_LOCAL_AND_POP($3a) MARK - MARK NUMBER ASSIGN_GLOBAL_AND_POP: NUMBER($2a) ASSIGN_GLOBAL_AND_POP($3a) MARK + MARK ASSIGN_LOCAL_NUMBER_AND_POP: ASSIGN_LOCAL_NUMBER_AND_POP($2a,$2b) MARK + MARK ASSIGN_GLOBAL_NUMBER_AND_POP: ASSIGN_GLOBAL_NUMBER_AND_POP($2a,$2b) MARK   MARK NEG_NUMBER ASSIGN_LOCAL_AND_POP: NEG_NUMBER($2a) ASSIGN_LOCAL_AND_POP($3a) MARK   MARK NEG_NUMBER ASSIGN_GLOBAL_AND_POP: NEG_NUMBER($2a) ASSIGN_GLOBAL_AND_POP($3a) MARK   MARK_AND_CONST1 ASSIGN_LOCAL_AND_POP: CONST1 ASSIGN_LOCAL_AND_POP($3a) MARK