[PATCH] D84491: [SimplifyCFG] Canonicalize branch predicates

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 11:36:00 PDT 2020


kuhar added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6047
+  // Change br (not X), label True, label False to: br X, label False, True
+  Value *X = nullptr;
+  if (CanonicalizeBranchPredicates &&
----------------
nit: would it be possible to come up with a more descriptive name? Maybe something like `newCond`, `conditionCandidate`, etc.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6053
+    BI->swapSuccessors();
+    BI->setOperand(0, X);
+    Changed = true;
----------------
`BI->setCondition(X)`?


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6064
+    // Swap destinations and condition.
+    CmpInst *Cond = cast<CmpInst>(BI->getCondition());
+    Cond->setPredicate(CmpInst::getInversePredicate(Pred));
----------------
nit: `auto *Cond = ...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84491



More information about the llvm-commits mailing list