On Tue, Feb 1, 2011 at 12:33 PM, David Gilbert david.gilbert@linaro.org wrote:
Hi, What do people understand to be the expected semantics of IT blocks in the cases below, of which there has been some confusion in relation to a recent Qt issue.
The code in question had a sequence something like:
comparison IT... EQ blahEQ TEQ BEQ
The important bits here are that we have an IT EQ block and two special cases:
1) There is a TEQ in the IT block - are all comparisons in the block allowed and do their effects immediately take effect? As far as I can tell this is allowed and any flag changes are used straight away;
Yes; yes; and: you're right. This was a specific intention, since there was always a common idiom on ARM of sequences like this:
CMP r0, #1 CMPEQ r1, #2 CMPEQ r2, #3 BEQ ...
with the effect of "if(r0==1 && r1==2 && r2==3) ..."
2) There is a BEQ at the end of the IT block, as far as I can tell, as long as the destination of the BEQ is close it shouldn't make any difference if the BEQ is included in the IT block or not.
Again, I believe you're right. The assembler will generate different code, because the explicit conditional branch encodings are not allowed in IT blocks. But the assembler takes care of this for you:
00000000 <f>: 0: d001 beq.n 6 <g>
versus
2: bf08 it eq 4: e7ff beq.n 6 <g>
00000006 <g>:
Both snippets are equivalent, though as you say, with IT you can insert more code between the branch and its destination before the assembler will barf with a fixup overflow, because the unconditional branch encoding (e000..e7fff) has more bits to express the branch offset.
Cheers ---Dave