[llvm-dev] Dumping branch weights in loop unroll phase

Florian Hahn via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 26 01:01:49 PST 2021


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>


More information about the llvm-dev mailing list