[LLVMdev] Loop Unrolling

Suresh Purini suresh.purini at gmail.com
Sat Jun 25 00:49:21 PDT 2011


Hello,

 I tried to do some small experiments on the loop unroll
transformation. Following is the Test Program. I compiled it as
follows:

$ opt -loop-rotate -debug-only=loop-unroll -loop-unroll
-unroll-count=2 test1.o -S -o test1.s

------------------
int a[1024];
int main()
{
 int i, sum=0;

 for(i=0; i<1024; ++i)
        sum += a[i];

 printf("%d",sum);
}
-------------------

I got the following compilation error. Any thoughts on why it is
happening. It is not supposed to crash right?

-------------------------------
Loop Unroll: F[main] Loop %for.body
  Loop Size = 7
UNROLLING loop %for.body by 2!
PHINode should have one entry for each predecessor of its parent basic block!
  %sum.0.lcssa = phi i32 [ %add.1, %for.inc.1 ]
 Broken module found, compilation aborted!
0  opt       0x0894589a
1  opt       0x08945627
2            0x00d9c400 __kernel_sigreturn + 0
3  libc.so.6 0x0013e34e abort + 382
4  opt       0x088f1d0d
5  opt       0x088f1a04
6  opt       0x088c9fc5
llvm::FPPassManager::runOnFunction(llvm::Function&) + 313
7  opt       0x088ca17f llvm::FPPassManager::runOnModule(llvm::Module&) + 109
8  opt       0x088ca46a llvm::MPPassManager::runOnModule(llvm::Module&) + 400
9  opt       0x088ca920 llvm::PassManagerImpl::run(llvm::Module&) + 122
10 opt       0x088cace5 llvm::PassManager::run(llvm::Module&) + 39
11 opt       0x084a6484 main + 4873
12 libc.so.6 0x00126e37 __libc_start_main + 231
13 opt       0x08496c21
Stack dump:
0.      Program arguments: /home/purini/llvmdbg/bin/opt -loop-rotate
-debug-only=loop-unroll -loop-unroll -unroll-count=4 test1.o -S -o
test1.s
1.      Running pass 'Function Pass Manager' on module 'test1.o'.
2.      Running pass 'Module Verifier' on function '@main'
Aborted



More information about the llvm-dev mailing list