Shubham Narlawar via llvm-dev
2021-Nov-24 16:46 UTC
[llvm-dev] Dumping branch weights in loop unroll phase
Hello, I am using a cross compiler built from llvm trunk source. Host - x86 Target - AArch64 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? 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. Thanks and Regards, Shubham -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211124/33557d24/attachment.html>
Florian Hahn via llvm-dev
2021-Nov-26 09:01 UTC
[llvm-dev] Dumping branch weights in loop unroll phase
Hi, Please avoid double posting.> On Nov 24, 2021, at 16:46, Shubham Narlawar via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello, > > I am using a cross compiler built from llvm trunk source. > > Host - x86 > Target - AArch64 > > 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? >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.` To see which loops have been unrolled, you can use optimization remarks, e.g. add ` -Rpass=loop-unroll `(https://clang.godbolt.org/z/W418qeaGc <https://clang.godbolt.org/z/W418qeaGc>) or `-fsave-optimization-record`. https://llvm.org/docs/Remarks.html <https://llvm.org/docs/Remarks.html>> 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.You can take a look at the metadata in LLVM IR (https://llvm.org/docs/BranchWeightMetadata.html <https://llvm.org/docs/BranchWeightMetadata.html>) Not sure if there’s a pass to dump them in a nice way. Cheers, Florian -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211126/a4f641bc/attachment.html>