[NFC][SimplifyCFG] SinkCommonCodeFromPredecessors(): reword comment about PR30244
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 28 Apr 2021 19:40:07 +0000 (22:40 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 28 Apr 2021 22:01:00 +0000 (01:01 +0300)
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

index 3bf5463..6f19453 100644 (file)
@@ -2041,11 +2041,11 @@ static bool SinkCommonCodeFromPredecessors(BasicBlock *BB,
   };
 
   if (Cond) {
-    // Check if we would actually sink anything first! This mutates the CFG and
-    // adds an extra block. The goal in doing this is to allow instructions that
-    // couldn't be sunk before to be sunk - obviously, speculatable instructions
-    // (such as trunc, add) can be sunk and predicated already. So we check that
-    // we're going to sink at least one non-speculatable instruction.
+    // It is always legal to sink common instructions from unconditional
+    // predecessors. However, if not all predecessors are unconditional,
+    // this transformation might be pessimizing. So as a rule of thumb,
+    // don't do it unless we'd sink at least one non-speculatable instruction.
+    // See https://bugs.llvm.org/show_bug.cgi?id=30244
     LRI.reset();
     unsigned Idx = 0;
     bool Profitable = false;