<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 26 Nov 2021 at 14:31, Florian Hahn <<a href="mailto:florian_hahn@apple.com" target="_blank">florian_hahn@apple.com</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"><div>Hi,<div><br></div><div>Please avoid double posting.<br></div></div></blockquote><div><br></div><div>Hello Florian and community,<br></div><div><br></div><div>Sure.</div><div> <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><div><div><br><blockquote type="cite"><div>On Nov 24, 2021, at 16:46, Shubham Narlawar via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr"><div>Hello,</div><div><br></div><div>I am using a cross compiler built from llvm trunk source.<br></div><div><br></div><div>Host - x86</div><div>Target - AArch64<br></div><div><br></div><div>I am seeing the same loop unroll dump before and after loop unroll pass using flags - "-O2 -funroll-loops". Is there a way to check whether the loop has unrolled or not?</div><div><br></div></div></div></blockquote><div><br></div><div>How are you dumping the IR before/after unrolling? You are comparing the IR after all optimizations, note that `-O2 already enables unrolling, so adding `-funroll-loops` shouldn’t change much. You can disable unrolling though, using `-fno-unroll-loops.` </div></div></div></div></blockquote><div><br></div><div><br></div><div>I was dumping using below command for AArch64 target -<br></div><div><br></div><div>clang-14 -O3 -Xclang -disable-llvm-passes -S -emit-llvm store.c -o store.ll                 //preparing for -O3 but don't run passes<br></div><div><br></div><div>[1]</div><div><br></div><div>I am getting same dump for below commands -<br></div><div><br></div><div>opt -S store.ll -loop-unroll -print-before=loop-unroll         <br></div><div>opt -S store.ll -loop-unroll -print-after=loop-unroll</div><div><br></div><div><div>[2]</div><div><br></div><div>In this case also, I am getting same dump for below commands -<br></div><div><br></div><div>opt -S store.ll -loop-unroll -print-before=loop-unroll -O2        <br></div><div>opt -S store.ll -loop-unroll -print-after=loop-unroll -O2<br></div></div><div><br></div><div>I am suspecting that I am comparing IR after all opts. Is the above method incorrect to find dump before and after loop unroll? Also, I think at -O2 some other pass is unrolling the loop to some extent?</div><div><br></div><div>Reference - <a href="https://gcc.godbolt.org/z/shbnG8f4W">https://gcc.godbolt.org/z/shbnG8f4W</a></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div><div><br></div><div>To see which loops have been unrolled, you can use optimization remarks, e.g. add ` -Rpass=loop-unroll `(<a href="https://clang.godbolt.org/z/W418qeaGc" target="_blank">https://clang.godbolt.org/z/W418qeaGc</a>)  or `-fsave-optimization-record`. <a href="https://llvm.org/docs/Remarks.html" target="_blank">https://llvm.org/docs/Remarks.html</a></div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div>As I am seeing both before and after loop unroll dumps as same, is there a way to dump branch weights? I tried flag "-stats" but I am not getting any warnings or actual branch weights.<br></div></div></div></blockquote><div><br></div>You can take a look at the metadata in LLVM IR (<a href="https://llvm.org/docs/BranchWeightMetadata.html" target="_blank">https://llvm.org/docs/BranchWeightMetadata.html</a>) Not sure if there’s a pass to dump them in a nice way.</div></div></div></blockquote><div><br></div><div>From the above link there does not seem any flag to be passed to clang to dump branch weights? It's fine even if it is not in a nice way. I am interested in solving this bug - <a href="https://bugs.llvm.org/show_bug.cgi?id=51185#c2">https://bugs.llvm.org/show_bug.cgi?id=51185#c2</a></div><div><br></div><div>(<span id="gmail-summary_container"><span id="gmail-short_desc_nonedit_display">Sub-optimal placement of loop exit blocks for AArch64 backend</span></span>)<br></div><div><br></div><div>Thanks and Regards,</div><div>Shubham</div><div><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><div><div><br></div><div><br></div><div>Cheers,</div><div>Florian</div></div></div></blockquote></div></div>