[PATCH] D19488: [CodeGenPrepare] use branch weight metadata to decide if a select should be turned into a branch

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 14:45:41 PDT 2016


spatel added inline comments.

================
Comment at: include/llvm/Target/TargetLowering.h:268
@@ +267,3 @@
+  virtual BranchProbability getPredictableBranchThreshold() const {
+    return BranchProbability(99, 100);
+  }
----------------
hfinkel wrote:
> Agreed. A command-line option to override the default would be significantly more convenient.
Yes - will fix and update the patch.

================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:4551
@@ +4550,3 @@
+
+  // If metadata tells us that the select condition is obviously predictable,
+  // then we want to replace the select with a branch.
----------------
Good point - we use it in splitBranchCondition() but forgot to update this path.
I'll fix that ahead of this patch.

================
Comment at: lib/IR/Metadata.cpp:1263
@@ +1262,3 @@
+
+  if (auto *ProfileDataName = dyn_cast<MDString>(ProfileData->getOperand(0)))
+    if (!ProfileDataName->getString().equals("branch_weights"))
----------------
Sure - I'll check-in the extra check + comment + variable name changes and update this.

================
Comment at: test/CodeGen/X86/cmov-into-branch.ll:118
@@ -96,2 +117,3 @@
+
 !0 = !{!"branch_weights", i32 1, i32 99}
 !1 = !{!"branch_weights", i32 1, i32 100}
----------------
Hmm - do you want to check for something different than 'weighted_select1()' above?


http://reviews.llvm.org/D19488





More information about the llvm-commits mailing list