What does this twi do? According to my powerpc docs, this would be a
no-op. Does this have some magic synchronizing powers on certain
implementations?
On all implementations; it's in the PowerPC architecture.
A data-dependent branch followed by an isync ensures that no
instructions after the isync in program order will be
(speculatively) executed, so the load that the twi depends
on has to complete before anything else is executed; in
particular, it's a barrier to keep MMIO reads ordered before
main-storage accesses.
Note that twi alone is not enough; it needs an isync as well.
Any other data-dependent branch instead of twi would do fine
as well.
Segher