[PATCH] D130757: Sub-optimal placement of loop exit blocks

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 13:18:33 PDT 2022


efriedma added a reviewer: Carrot.
efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopUnroll.cpp:394
+    LLVMMetadataRef branch_weights =
+        LLVMMDStringInContext2(LLVMGetGlobalContext(), "branch_weights", 14);
+    LLVMMetadataRef weight1 =
----------------
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()`.


================
Comment at: llvm/lib/Transforms/Utils/LoopUnroll.cpp:398
+    LLVMMetadataRef weight2 =
+        LLVMValueAsMetadata(LLVMConstInt(LLVMIntType(32), 80, 0));
+    LLVMMetadataRef mds[] = {branch_weights, weight1, weight2};
----------------
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.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130757/new/

https://reviews.llvm.org/D130757



More information about the llvm-commits mailing list