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

David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 14:24:02 PDT 2016


davidxl added inline comments.

================
Comment at: include/llvm/Target/TargetLowering.h:268
@@ +267,3 @@
+  virtual BranchProbability getPredictableBranchThreshold() const {
+    return BranchProbability(99, 100);
+  }
----------------
hard coding default value like this make it hard to do performance experiment -- suggest an internal option to control

================
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.
----------------
Why is unpredictable meta data is not looked at here?

================
Comment at: lib/IR/Metadata.cpp:1263
@@ +1262,3 @@
+
+  if (auto *ProfileDataName = dyn_cast<MDString>(ProfileData->getOperand(0)))
+    if (!ProfileDataName->getString().equals("branch_weights"))
----------------
This fix  can be committed as a different patch?

================
Comment at: test/CodeGen/X86/cmov-into-branch.ll:99
@@ -95,3 +98,3 @@
 
 !0 = !{!"branch_weights", i32 1, i32 99}
 !1 = !{!"branch_weights", i32 1, i32 100}
----------------
Worth adding a test case where probability is < 1% ?


http://reviews.llvm.org/D19488





More information about the llvm-commits mailing list