[LV] Adjust trip count based on IsOrdered in widenPHIInstruction (NFC).
authorFlorian Hahn <flo@fhahn.com>
Sat, 26 Jun 2021 12:11:18 +0000 (13:11 +0100)
committerFlorian Hahn <flo@fhahn.com>
Sat, 26 Jun 2021 12:13:25 +0000 (13:13 +0100)
Suggested in D104197, avoids the early exit.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

index f28dbaa..b53c144 100644 (file)
@@ -4801,11 +4801,8 @@ void InnerLoopVectorizer::widenPHIInstruction(Instruction *PN,
     bool IsOrdered = State.VF.isVector() &&
                      Cost->isInLoopReduction(cast<PHINode>(PN)) &&
                      Cost->useOrderedReductions(*RdxDesc);
-
-    for (unsigned Part = 0; Part < State.UF; ++Part) {
-      // This is phase one of vectorizing PHIs.
-      if (Part > 0 && IsOrdered)
-        return;
+    unsigned LastPartForNewPhi = IsOrdered ? 1 : State.UF;
+    for (unsigned Part = 0; Part < LastPartForNewPhi; ++Part) {
       Value *EntryPart = PHINode::Create(
           VecTy, 2, "vec.phi", &*LoopVectorBody->getFirstInsertionPt());
       State.set(PhiR, EntryPart, Part);