Wang, Luyuan (MU-Student) via llvm-dev
2019-Apr-23 03:54 UTC
[llvm-dev] How to know pass dependencies?
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190423/6eec7ef9/attachment.html>
Doerfert, Johannes via llvm-dev
2019-Apr-23 16:28 UTC
[llvm-dev] How to know pass dependencies?
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>
You do not need to add the dependencies of a transform pass in command line, since they will be added by the pass manager. If a pass , like "-loop-interchange", can optimize the code, there must have optimization points in the code that can be optimized by this pass. If you want to know the dependencies of a transform pass, you can read it's source code . In the getAnalysisUsage function, you will find the required dependencies of the pass. At 2019-04-24 00:18:54, "Wang, Luyuan \\(MU-Student\\) via llvm-dev" <llvm-dev at lists.llvm.org> 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190424/1d90712f/attachment.html>