[PATCH] D22551: CodeGen: If Convert blocks that would form a diamond when tail-merged.

David Li via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 15:58:51 PDT 2016


davidxl added inline comments.

================
Comment at: lib/CodeGen/IfConversion.cpp:674
@@ +673,3 @@
+/// extracted
+bool IfConverter::ValidDiamondTail(
+    BBInfo &TrueBBI, BBInfo &FalseBBI,
----------------
Document the difference between this pattern vs ValidDiamond?

Also since there is no common tail shared between truebb and falsebb, the shape is not really 'Diamond'. Perfhaps make it named "ValidDiamondWithTailCommonned' ? to indicate the shape will be diamond if the tail is commonned?

================
Comment at: lib/CodeGen/IfConversion.cpp:692
@@ +691,3 @@
+  if (!TT)
+    TT = getNextBlock(TrueBBI.BB);
+  if (!TF)
----------------
is 'fallthough' check needed here?

================
Comment at: lib/CodeGen/IfConversion.cpp:702
@@ +701,3 @@
+    return false;
+  if  (TrueBBI.BB->pred_size() > 1 || FalseBBI.BB->pred_size() > 1)
+    return false;
----------------
Can this check be moved earlier? If so, common check can be extracted and shared across this and ValidDiamond.

================
Comment at: lib/CodeGen/IfConversion.cpp:716
@@ +715,3 @@
+    return false;
+  if (TF == FT && TT == FF)
+    ReverseBranchCondition(FalseBBI);
----------------
Merge these two :

  if (TF == FT && TT == FF) {
      if (! Reversable)
           return false;
      reverse ...
   }

================
Comment at: lib/CodeGen/IfConversion.cpp:734
@@ +733,3 @@
+  // portion contained the extra cost.
+  auto recalculateCostsAndClobbers = [&](
+      MachineBasicBlock::iterator &BIB,
----------------
Better move this out of line to improve readability.

================
Comment at: lib/CodeGen/IfConversion.cpp:739
@@ +738,3 @@
+    std::vector<MachineOperand> PredDefs;
+    while (BIB != BIE) {
+      // Skip dbg_value instructions. These do not count.
----------------
I have not looked in details here. Is there existing code that can be refactored/reused by any chance? 


https://reviews.llvm.org/D22551





More information about the llvm-commits mailing list