Skip to content

Commit

Permalink
improve optimization of SetSTN
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawrence D'Oliveiro committed Oct 17, 2014
1 parent cfa3ac4 commit 8fb0232
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/dvdcompile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,20 +1435,28 @@ void vm_optimize(const unsigned char *obuf, unsigned char *buf, unsigned char **
// 1. this instruction sets subtitle/angle/audio
// 2. the next instruction sets subtitle/angle/audio
// 3. they both set them the same way (i.e. immediate/indirect)
// 4. there are no references to the second instruction
// 4. if either includes a comparison or link, they both include the same
// 5. there are no references to the second instruction
// then
// combine
if
(
b + 8 != *end
&&
(b[0] & 0xEF) == 0x41
(b[0] & 0xEF) == 0x41 /* SetSTN */
&&
b[1] == 0 // step 1
(b[1] & 0xf0) == 0
/* fixme: allow merging of linked versions, but not conditional
versions for now, until I add checks to ensure comparison doesn't
involve registers changed by set */
&&
b[0] == b[8]
b[0] == b[8] // step 2 & 3
&&
b[1] == b[9] // step 2 & 3
b[1] == b[9]
&&
b[6] == b[14]
&&
b[7] == b[15]
&&
!isreferenced(buf, *end, curline + 1)
)
Expand Down

0 comments on commit 8fb0232

Please sign in to comment.