|
From: Julian S. <js...@ac...> - 2007-02-15 19:46:13
|
> (2) Correct it and show how to do it the right way
>
> Solution (2) complicates lackey (a little?), but if it is also
> a tutorial about branch counting, it should be correct.
I agree. Sounds like a good solution to me.
> So perhaps a third solution would be:
> (3) Not invert the meaning of conditions in the "pre-instr IR optimisation"
> phase
That is hard to avoid given that IR optimisation does some simple
loop unrolling for single-bb loops. eg, it will unroll your
top:
add %eax,%edx
add $0x1,%eax
cmp $0xf4240,%eax
jl top
producing IR as if you had written
top:
add %eax,%edx
add $0x1,%eax
cmp $0xf4240,%eax
jnl after
add %eax,%edx
add $0x1,%eax
cmp $0xf4240,%eax
jl top
after:
See, the middle exit is now inverted.
Also, if we ever do more aggressive block formation which speculatively
chases across conditional branches ("trace formation"), then some branch
conditions will have to be inverted - it is unavoidable.
J
|