[llvm-dev] How to know pass dependencies?

Doerfert, Johannes via llvm-dev llvm-dev at lists.llvm.org
Tue Apr 23 09:28:38 PDT 2019


Hi Luyuan Wang,

when I want to try out passes I do this:

1) Create an LLVM-IR file so you see what is actually fed into them:
./bin/clang -O3 -mllvm -disable-llvm-optzns interchange.c -emit-llvm -S -o interchange.ll

2) "Prepare" the IR, this could involve more steps:
./bin/opt -mem2reg interchange.ll -o interchange.ll

3) Run the passes potentially also print the pass debug output:
./bin/opt -loop-interchange -debug-only=loop-interchange interchange.ll -analyze

Calling populateWorklist on Func: main Loop: %for.cond
Processing LoopList of size = 2
Found 1 Loads and Stores to analyze
Processing Inner Loop Id = 1 and OuterLoopId = 0
Loops where the latch is not the exiting block are not supported currently.
Not legal because of current transform limitation
Not interchanging loops. Cannot prove legality.

4) Use the debug output to figure out what is wrong. (see the not
   supported line)

5) "Prepare" the IR further:
./bin/opt -loop-rotate interchange.ll -o interchange.ll

6) Try it again:
./bin/opt -loop-interchange -debug-only=loop-interchange interchange.ll -analyze

Calling populateWorklist on Func: main Loop: %for.body
Processing LoopList of size = 2
Found 1 Loads and Stores to analyze
Processing Inner Loop Id = 1 and OuterLoopId = 0
Checking if loops are tightly nested
Checking instructions in Loop header and Loop latch
Loops are perfectly nested
Loops are legal to interchange
Cost = -1
Calling Split Inner Loop
splitInnerLoopLatch done
splitting InnerLoopHeader done
adjustLoopBranches called
Loops interchanged.


I hope this helps :)

Cheers,
  Johannes

P.S.
I did not actually run all the commands like this, typos are to be
expected.



On 04/23, Wang, Luyuan (MU-Student) via llvm-dev wrote:
> Dear LLVM developers,
> 
> I'm a beginner with LLVM, and I want to see how different loop optimization passes influence the performance. For example, I've generated IR code, and I would like to use "Loop Interchange" as the only loop optimization pass.
> 
> However, when I simply used `opt -loop-interchange input.ll -S -o output.ll` command, the IR code didn't change. I guess the reason may be the "-loop-interchange" pass also depends on other passes, so I should also specify some other passes before the loop interchange pass. But how do I know these dependencies?
> 
> Here is my C program to test loop interchange:
> 
> int main() {
>   int i=0;
>   int j=0;
>   int a[333][222];
>   for (i=0; i <222; i++) {
>         for (j=0; j <333; j++) {
>                 a[j][i] = i * j;
>         }
>   }
>   return 0;
> }
> 
> 
> I also tried this command, but still no influence:
> 
> opt -mem2reg -simplifycfg -loops -lcssa -loop-simplify -loop-rotate -loop-
> interchange input.ll -S -o output.ll
> 
> Thank you so much.
> 
> Best,
> 
> Luyuan Wang
> 
> 

> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


-- 

Johannes Doerfert
Researcher

Argonne National Laboratory
Lemont, IL 60439, USA

jdoerfert at anl.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190423/986ad8c7/attachment.sig>


More information about the llvm-dev mailing list