[PATCH] Add a speculative execution pass

Jingyue Wu jingyue at google.com
Tue May 5 10:52:27 PDT 2015


================
Comment at: lib/Transforms/Scalar/SpeculativeExecution.cpp:60
@@ +59,3 @@
+
+static cl::opt<unsigned> SpecExecMaxNotHoisted(
+    "spec-exec-max-not-hoisted", cl::init(5), cl::Hidden,
----------------
Comment on why this threshold is necessary. My understanding is the NVIDIA driver only speculates a limited number of instructions. If too many instructions are left behind, the conditional basic block won't be executed in the SASS level. 

================
Comment at: lib/Transforms/Scalar/SpeculativeExecution.cpp:69
@@ +68,3 @@
+  static char ID;
+  SpeculativeExecution(): FunctionPass(ID) {}
+
----------------
Add a constructor that takes `spec-exec-max-speculation-cost` and `spec-exec-max-not-hoisted` as parameters. This allows embedded uses of LLVM (e.g., users can programmatically create these passes with their desired thresholds). 

================
Comment at: lib/Transforms/Scalar/SpeculativeExecution.cpp:113
@@ +112,3 @@
+  if (Succ1.getSinglePredecessor() != nullptr &&
+      Succ1.getTerminator()->getNumSuccessors() == 1 &&
+      Succ1.getTerminator()->getSuccessor(0) == &Succ0) {
----------------
Can we make a new interface `getSingleSuccessor()`? 

================
Comment at: lib/Transforms/Scalar/SpeculativeExecution.cpp:141
@@ +140,3 @@
+  // benchmarking. There is likely room for improvement.
+  switch (Operator::getOpcode(I)) {
+    case Instruction::GetElementPtr:
----------------
Should we consider `ConstantExpr` free? 

================
Comment at: lib/Transforms/Scalar/SpeculativeExecution.cpp:180
@@ +179,3 @@
+
+  unsigned TotalCost = 0;
+  for (auto I = FromBlock.begin(), End = FromBlock.end(); I != End; ++I) {
----------------
TotalSpeculationCost

================
Comment at: lib/Transforms/Scalar/SpeculativeExecution.cpp:181
@@ +180,3 @@
+  unsigned TotalCost = 0;
+  for (auto I = FromBlock.begin(), End = FromBlock.end(); I != End; ++I) {
+    const unsigned Cost = ComputeSpeculationCost(I);
----------------
```
for (auto &I : FromBlock)
```

http://reviews.llvm.org/D9360

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list