Problem migrating from llvm 2.9 to 3.0

Hello, I’m moving a compiler pass from llvm 2.9 to 3.0, and I’m getting some strange extra store instructions when optimizing the code.

For example, in the code that is in the attachments (On block for.body111 for 2.9 and block for.body67 for 3.0), the number of stores goes from 1 to 10. And since the compiler pass adds some verification code before each store, this leads to some performance problems.

The resulting .ll is obtained in this way:
clang -O3 fir2dim.c -S -emit-llvm -o fir2dim.ll
llvm-as fir2dim.ll
opt -O3 fir2dim.bc > fir2dim.opt.bc
llvm-dis fir2dim.opt.bc

Any idea why this is happening ?

Thanks,

Juan

fir2dim.c (1.89 KB)

fir2dim.opt.2.9.ll (9.3 KB)

fir2dim.opt.3.0.ll (10.9 KB)

Hi Juan,

Hello, I'm moving a compiler pass from llvm 2.9 to 3.0, and I'm getting some
strange extra store instructions when optimizing the code.

For example, in the code that is in the attachments (On block *for.body111* for
2.9 and block *for.body67 *for 3.0), the number of stores goes from 1 to 10. And
since the compiler pass adds some verification code before each store, this
leads to some performance problems.

The resulting .ll is obtained in this way:
clang -O3 fir2dim.c -S -emit-llvm -o fir2dim.ll
llvm-as fir2dim.ll
opt -O3 fir2dim.bc > fir2dim.opt.bc
llvm-dis fir2dim.opt.bc

Any idea why this is happening ?

maybe it completely unrolled this loop:

                                 for (i = 0 ; i < 9 ; i++) {
                                         *poutput += *pcoeff++ * *(parray++ +(i / 3) * ARRAYDIM) ;
                                 }

?

Ciao, Duncan.

Hi Duncan,
In in both versions of llvm it unrolls that loop. But I don’t understand why in 2.9 it uses registers for intermediate results and only one store, and in the other version, it performs stores for every intermediate result.

I’ve tried compiling on llvm 3.0 using exactly the same optimizations, in the same order as in 2.9 and I still get the same problem. Maybe a optimization has changed from 2.9 to 3.0 ?

Thanks,

Juan