On 20.06.2011, at 06:56, Robert Purves <listrp at gmail.com> wrote: > Which parts of clang/llvm source should I read to learn how the loop is magically optimized away? Look at LLVM's ScalarEvolution analysis. It's invoked by the loop optimizer passes and performs the "magic" computations that allow static execution of loops.