Skip to content

Commit 1c727ba

Browse files
committed
[VPlan] Mark BranchOnCount and BranchOnCond as having side effects (NFC)
BranchOnCount and BranchOnCond do not read memory, but cannot be moved. Mark them as having side-effects, but not reading/writing memory, which more accurately models that above. This allows removing some special checking for branches both in the current code and future patches.
1 parent 82d5622 commit 1c727ba

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,12 @@ bool VPRecipeBase::mayHaveSideEffects() const {
162162
case VPPredInstPHISC:
163163
case VPVectorEndPointerSC:
164164
return false;
165-
case VPInstructionSC:
166-
return mayWriteToMemory();
165+
case VPInstructionSC: {
166+
auto *VPI = cast<VPInstruction>(this);
167+
return mayWriteToMemory() ||
168+
VPI->getOpcode() == VPInstruction::BranchOnCount ||
169+
VPI->getOpcode() == VPInstruction::BranchOnCond;
170+
}
167171
case VPWidenCallSC: {
168172
Function *Fn = cast<VPWidenCallRecipe>(this)->getCalledScalarFunction();
169173
return mayWriteToMemory() || !Fn->doesNotThrow() || !Fn->willReturn();
@@ -1241,6 +1245,8 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
12411245
case Instruction::Select:
12421246
case Instruction::PHI:
12431247
case VPInstruction::AnyOf:
1248+
case VPInstruction::BranchOnCond:
1249+
case VPInstruction::BranchOnCount:
12441250
case VPInstruction::Broadcast:
12451251
case VPInstruction::BuildStructVector:
12461252
case VPInstruction::BuildVector:

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4174,7 +4174,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
41744174
unsigned VFMinVal = VF.getKnownMinValue();
41754175
SmallVector<VPInterleaveRecipe *> StoreGroups;
41764176
for (auto &R : *VectorLoop->getEntryBasicBlock()) {
4177-
if (isa<VPCanonicalIVPHIRecipe>(&R) || match(&R, m_BranchOnCount()))
4177+
if (isa<VPCanonicalIVPHIRecipe>(&R))
41784178
continue;
41794179

41804180
if (isa<VPDerivedIVRecipe, VPScalarIVStepsRecipe>(&R) &&

0 commit comments

Comments
 (0)