<div dir="ltr">Well, I think that the easiest thing to do is something like that: <a href="https://godbolt.org/z/xYWc7e">https://godbolt.org/z/xYWc7e</a><div>You basically make a simple regex saying show me anything that passes matching loop or licm (loop-invariant code motion) have reported.</div><div><br></div><div>If you worry you may have missed a pass you want with this regex, you can look either to the pipeline: <a href="https://godbolt.org/z/dvWchh">https://godbolt.org/z/dvWchh</a> (note that regex should match argument names, not actual names e.g., -licm vs Loop-Invariant Code Motion)</div><div>Or you can take a look at the list of LLVM passes: <a href="https://llvm.org/docs/Passes.html">https://llvm.org/docs/Passes.html</a></div><div>Most loop passes have inside them so you should be mostly ok.</div><div><br></div><div>For larger codes, or for easier parsing, you can just use -fsave-optimization-record, like: clang test.c -c -O2 -fsave-optimization-record</div><div>It will basically show you the same things but in a more structured format and it will output a .yaml file.</div><div>You can then sort out the passes you don't want either yourself or by using: <a href="https://clang.llvm.org/docs/UsersManual.html#cmdoption-foptimization-record-passes">https://clang.llvm.org/docs/UsersManual.html#cmdoption-foptimization-record-passes</a></div><div><br></div><div>If you're not satisfied with any of that, well, the next step I think is -print-after-all (I mentioned above what it is and how to use it) because e.g., some passes may not create reports.</div><div>Ideally, you would like something that shows you only the passes that changed the IR, and there is supposed to be such a thing, -print-changed, but for some reason it</div><div>doesn't work.</div><div><br></div><div>Please try those options and tell me whether they help.</div><div><br></div><div>Best,</div><div>Stefanos</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Παρ, 29 Ιαν 2021 στις 7:34 μ.μ., ο/η Sudakshina Dutta <<a href="mailto:sudakshina@iitgoa.ac.in">sudakshina@iitgoa.ac.in</a>> έγραψε:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Dear Stefanos,<div><br></div><div>I want to know whether after loop optimization, llvm indicates which loop is optimized and what all optimizations have been applied successfully to the individual loop which is optimized. Suppose, the loop L1 is optimized and the optimizations t1, t2, t3 have been attempted and are actually applied also. Again, the loop L2 is optimized and  <span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">the optimizations t1, t2, t3 have been attempted and only t1 is finally applied. Does LLVM output the following ?</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium"><br></span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Loop L1 : optimizations t1, t2, t3</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Loop L2 : optimization t1</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium"><br></span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Thanks,</span></div><div><span style="color:rgb(0,0,0);font-family:-webkit-standard;font-size:medium">Sudakshina</span></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 29, 2021 at 10:13 PM Michael Kruse <<a href="mailto:llvmdev@meinersbur.de" target="_blank">llvmdev@meinersbur.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am Fr., 29. Jan. 2021 um 06:18 Uhr schrieb Sudakshina Dutta via<br>
llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>:<br>
> Thanks for all your reply. I have one simple question to ask. I am new to llvm. I know that the loop to be optimized has to be enclosed between #pragma scop and #pragma endoscop.<br>
<br>
#pragma scop/endscop are used by polyhedral source-to-source<br>
optimizers such as ppcg[1] and OpenScop[2]. LLVM's polyhedral<br>
optimizer Polly does not use them.<br>
<br>
Polly has several report options available, such as<br>
`-Rpass-analysis=polly-scops`, `-mllvm -polly-report`, `-mllvm<br>
-polly-show`.<br>
<br>
[1] <a href="https://repo.or.cz/ppcg.git" rel="noreferrer" target="_blank">https://repo.or.cz/ppcg.git</a><br>
[2] <a href="http://icps.u-strasbg.fr/~bastoul/development/openscop/index.html" rel="noreferrer" target="_blank">http://icps.u-strasbg.fr/~bastoul/development/openscop/index.html</a><br>
<br>
Michael<br>
</blockquote></div>
</blockquote></div>