Skip to content

Commit c6bcdf0

Browse files
committed
Add detailed comments
1 parent 09159bd commit c6bcdf0

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,8 +3179,28 @@ bool SMSchedule::normalizeNonPipelinedInstructions(
31793179
<< " to " << NewCycle << " Instr:" << *SU.getInstr());
31803180
}
31813181

3182-
// There is a case where the `NewCycle` is too large to be scheduled in
3183-
// Stage 0. In this case, we reject the schedule.
3182+
// We traverse the SUs in the order of the original basic block. Computing
3183+
// NewCycle in this order normally works fine because all dependencies
3184+
// (except for loop-carried dependencies) don't violate the original order.
3185+
// However, an artificial dependency (e.g., added by CopyToPhiMutation) can
3186+
// break it. That is, there may be exist an artificial dependency from
3187+
// bottom to top. In such a case, NewCycle may become too large to be
3188+
// scheduled in Stage 0. For example, assume that Inst0 is in DNP in the
3189+
// following case:
3190+
//
3191+
// | Inst0 <-+
3192+
// SU order | | artificial dep
3193+
// | Inst1 --+
3194+
// v
3195+
//
3196+
// If Inst1 is scheduled at cycle N and is not at Stage 0, then NewCycle of
3197+
// Inst0 must be greater than or equal to N so that Inst0 is not be
3198+
// scheduled at Stage 0. In such cases, we reject this schedule at this
3199+
// time.
3200+
// FIXME: The reason for this is the existence of artificial dependencies
3201+
// that are contradict to the original SU order. If ignoring artificial
3202+
// dependencies does not affect correctness, then it is better to ignore
3203+
// them.
31843204
if (FirstCycle + InitiationInterval <= NewCycle)
31853205
return false;
31863206

0 commit comments

Comments
 (0)