How to loop unswitch?

Stephan Ceram <>
29 Jul 2008 20:52:14 GMT

          From comp.compilers

Related articles
How to loop unswitch? (Stephan Ceram) (2008-07-29)
| List of all articles for this month |

From: Stephan Ceram <>
Newsgroups: comp.compilers
Date: 29 Jul 2008 20:52:14 GMT
Organization: Compilers Central
Keywords: optimize, question
Posted-Date: 29 Jul 2008 19:22:42 EDT


I've a question about the compiler optimization "loop unswitching" and
its compiler heuristics.

In case of a single loop independent if/if-else statement within the
loop, there's not much choice for the conditional to be moved outside
of the loop.

But what are reasonable compiler decisions when a loop holds multiple
loop independent conditions? It might be not a good idea to unswitch
the loop separately for each condition since this would result in
multiple duplicates of the loop body possibly increasing the code size
too heavily. Thus, a compiler will very likely evaluate the conditions
with their then/else parts and begin with the most promising
condition. Any ideas how such an evaluation might work?

Does it even make sense to combine several conditions and move this
new mixed condition outside the loop?


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.