[PATCH] D120231: [SelectOpti][3/5] Base Heuristics

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 16:11:15 PDT 2022


davidxl added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectOptimize.cpp:99
   bool optimizeSelects(Function &F);
+  void optimizeSelectsBase(Function &F, SelectGroups &ProfSIGroups);
+  void optimizeSelectsInnerLoops(Function &F, SelectGroups &ProfSIGroups);
----------------
add some comments to the methods.


================
Comment at: llvm/lib/CodeGen/SelectOptimize.cpp:352
+
+  // If unpredictable, branch form is more profitable.
+  if (SI->getMetadata(LLVMContext::MD_unpredictable)) {
----------------
is less profitable?


================
Comment at: llvm/lib/CodeGen/SelectOptimize.cpp:413
+
+void SelectOptimize::getOneUseSlice(Instruction *I,
+                                    SmallVector<Instruction *, 2> &Slice) {
----------------
This function deserves more comments in the code.


================
Comment at: llvm/lib/CodeGen/SelectOptimize.cpp:431
+    // Avoid considering instructions in outer or independent loops, or non-loop
+    // instructions (instructions with potentially much less frequency than the
+    // operand of the select).
----------------
non-loop regions?


================
Comment at: llvm/lib/CodeGen/SelectOptimize.cpp:444
+        continue;
+    }
+
----------------
should the relative hotness of II be checked instead of looking at the loop context?

Also It might worth check if the instructions in slice can actually be wrapped in the cold branch -- checking hasOneUse is for this, but is it more restricted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120231



More information about the llvm-commits mailing list