[llvm-dev] How to use the pass 'Unroll and Jam'

ZHEN WEI via llvm-dev llvm-dev at lists.llvm.org
Wed Apr 24 23:42:52 PDT 2019

Dear LLVM developers,

Recently I want to try the pass '-loop-unroll-and-jam' to observe how the
IR is transformed, but I don't see the IR changed after doing the following

Here are the details for preparing my experiment and I have tried the LLVM
6, 7 and 8:

1) Simple 2D array source code (loop.c) is given

#define M 32768
#define N 32768

double a[M][N], b[M][N], c[M][N];

int main() {
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            c[i][j] = a[i][j] + b[i][j];
    return 0;

2) Create an LLVM IR file
./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll

3) Run the 'unroll-and-jam' pass
./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll

I added the option '--debug-pass=Structure' to the opt, and I can see the
'Unroll and Jam loops' indeed executed by the Loop Pass Manager.
   ModulePass Manager
       FunctionPass Manager
        Dominator Tree Construction
        Basic Alias Analysis (stateless AA impl)
        Function Alias Analysis Results
        Natural Loop Information
        Scalar Evolution Analysis
        Dependence Analysis
        Canonicalize natural loops
        LCSSA Verifier
        Loop-Closed SSA Form Pass
        Loop Pass Manager
          Unroll and Jam loops
        Module Verifier
       Print Module IR

I also tried to add the option '-debug' to the opt to see if there is the
debug information printed by LoopUnrollAndJam, but nothing.

Thank you very much.
Zhen Wei (魏禛)
Master Student
Department of Computer Science & Information  Engineering
National Taiwan University
Email:  zhenwei.tw at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190425/995af7e9/attachment.html>

More information about the llvm-dev mailing list