LoopRotate: Fix avoiding copy_value hoisted to the pre-header

copy_value is marked as having no side effects.
Teach LoopRotate to avoid moving it to the pre header and instead duplicate it while rotating the loop.
This commit is contained in:
Meghana Gupta
2022-12-03 22:28:29 -08:00
parent 2e0cc04ba1
commit e23fe89129
2 changed files with 42 additions and 0 deletions

View File

@@ -116,6 +116,7 @@ canDuplicateOrMoveToPreheader(SILLoop *loop, SILBasicBlock *preheader,
if (!inst->mayHaveSideEffects() && !inst->mayReadFromMemory() &&
!isa<TermInst>(inst) &&
!isa<AllocationInst>(inst) && /* not marked mayhavesideeffects */
!isa<CopyValueInst>(inst) &&
hasLoopInvariantOperands(inst, loop, invariants)) {
moves.push_back(inst);
invariants.insert(inst);