compiler construction - LLVM fails to detect very simple loop trip count -


i'm trying understand how loop trip count calculation happens in llvm using scalar evolution analysis. however, can't simple test case work.

i have following test program:

// bug.cpp int main() {   (int = 0; < 16; i++) {     // nothing   }   return 0; } 

which compile this:

$ clang++ -o0 -emit-llvm -c -o bug.bc bug.cpp 

and analyze this:

$ opt -analyze -indvars -loop-simplify -scalar-evolution < bug.bc 

but output of scalar evolution this:

... determining loop execution counts for: @main loop %for.cond: unpredictable backedge-taken count. loop %for.cond: unpredictable max backedge-taken count. 

why simple loop have unpredictable trip count? doing wrong in invoking analysis? llvm 3.4.

solved of related question:

the use of getsmallconstanttripcount method of loop in llvm

add mem2reg optimization pass , trip count correctly computed.

$ opt -analyze -mem2reg -indvars -loop-simplify -scalar-evolution < bug.bc 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -