Optimize AndNext chain comparisons that span consecutive bytes
It seems like when AndNext chains are generated, no optimization is done to merge bytes into words and words into dwords. For example, the function shown below generates an AndNext chain where consecutive bytes are compared to their deltas 8 bits at a time. Since the final condition is a reset, I think these could be reduced to dwords.
function reset_on_same_skillset(slot) {
trigger = always_true()
for i in range(0, 127) {
skills = byte(0x1234 + slot * 0x100 + 12 + i)
trigger = trigger && skills == prev(skills)
}
return never(trigger)
}
The optimizer explicitly does not merge adjacent bytes under the assumption that they could have separate notes, and combining the bytes would make future debugging harder.
See also https://github.com/Jamiras/RATools/issues/32#issuecomment-464241535
merge bits into lower/upper/byte: https://github.com/Jamiras/RATools/blob/master/Tests/Parser/AchievementBuilderTests.cs#L415
- does not merge consecutive bytes to 16-bit or 32-bit - this is typically undesirable as bytes have separate code notes
It might be reasonable to combine bytes if they don't have separate code notes, or if the range is annotated with with a length (i.e. "[60 bytes] skill flags")