[PATCH] Thumb2: When applying branch optimizations, visit branches in reverse order.

Peter Collingbourne peter at pcc.me.uk
Thu Apr 23 12:05:01 PDT 2015

The test case provides a good illustration of this. In that case, we have:

branch to L if x != 0
64 bytes of instructions
branch to L if y != 0
60 bytes of instructions

If we visit the first branch first, there will be 64+4+60=128 bytes of instructions between the branch and the label, which is too large for the backend to apply the cbnz optimization. However, if we visit the second branch first, the backend can apply the cbnz optimization to that branch, shrinking it to 2 bytes, and when we visit the first branch the calculation becomes 64+2+60=126, which is just small enough that the cbnz optimization can be applied.



More information about the llvm-commits mailing list