[PATCH] Select elimination pass

David Majnemer david.majnemer at gmail.com
Tue Sep 2 15:06:03 PDT 2014


================
Comment at: lib/Transforms/Scalar/SelectElimination.cpp:128-131
@@ +127,6 @@
+    return false;
+  BranchInst *BI = cast<BranchInst>(BB->getTerminator());
+  if (BI->getNumSuccessors() != 2)
+    return false;
+  ICmpInst *IC = dyn_cast<ICmpInst>(BI->getCondition());
+  if (IC && IC->getOperand(0) !=  SI)
----------------
auto would be more concise here, the type is also in the dyn_cast template argument.

================
Comment at: lib/Transforms/Scalar/SelectElimination.cpp:145-146
@@ +144,4 @@
+  BranchInst *BI = cast<BranchInst>(SI->getParent()->getTerminator());
+  ICmpInst *ICIU = dyn_cast<ICmpInst>(BI->getCondition());
+  if (ICIU) {
+    ICmpInst::Predicate PredU = ICIU->getPredicate();
----------------
You can fold this dyn_cast into the if.

================
Comment at: lib/Transforms/Scalar/SelectElimination.cpp:173
@@ +172,3 @@
+
+  bool changed = false;
+  DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
----------------
Should be capitalized.

================
Comment at: lib/Transforms/Scalar/SelectElimination.cpp:184-185
@@ +183,4 @@
+        SelectInst *SI = cast<SelectInst>(I);
+        ICmpInst *ICID = dyn_cast<ICmpInst>(SI->getCondition());
+        if (ICID) {
+          ICmpInst::Predicate Pred = ICID->getPredicate();
----------------
You can fold these together too.

http://reviews.llvm.org/D5156






More information about the llvm-commits mailing list