[PATCH] D157462: LoopRotate: Add code to update branch weights

Paul Kirth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 13:44:52 PDT 2023


paulkirth added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopRotationUtils.cpp:291-306
+  uint32_t ExitCount0; // aka x0
+  if (!ConditionalPreHeader) {
+    // pre-header turned into an unconditional jump.
+    ExitCount0 = 0;
+  } else {
+    // Here we cannot know how many 0-trip count loops we have, so we guess:
+    if (Weights[1] > Weights[0]) {
----------------
This could probably be a helper function. It would also allow for expressive names for the `Weight[0]`/`Weight[1]` values, which will probably make it easier to follow. 

Alternatively, you could group all of these counts into a struct. I'm not convinced that is worth it in this case, but it may make the code simpler to reason about and keep all the logic regarding the heuristic together.

This does come down to personal coding style, so don't consider these suggestions blocking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157462



More information about the llvm-commits mailing list