This is an archive of the discontinued LLVM Phabricator instance.

Sub-optimal placement of loop exit blocks
Needs ReviewPublic

Authored by rajkrthakur on Jul 29 2022, 4:33 AM.

Details

Summary

This draft patch assigns probabilistic metadata to the branch for the required block placement

This resolves https://github.com/llvm/llvm-project/issues/50529

TODO - Add unit tests.

Diff Detail

Event Timeline

rajkrthakur created this revision.Jul 29 2022, 4:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 4:33 AM
rajkrthakur requested review of this revision.Jul 29 2022, 4:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 4:33 AM
Carrot added a subscriber: Carrot.Aug 19 2022, 8:16 AM
efriedma added inline comments.
llvm/lib/Transforms/Utils/LoopUnroll.cpp
394

Please avoid using the LLVM C API from C++ code. Please just use the C++ API (for example, MDString::get).

You can get the LLVMContext with something like LatchBI->getContext().

398

These weights seem sort of random; do we have any reason to think they're accurate? The default heuristics for branch weights should assume that loop backedges are likely.