Skip to content

[MachinePipeliner] Pipeliner Doesn't Consider Phis in computeStart #117496

@mmarjieh

Description

@mmarjieh

When trying to schedule an instruction X and it has an input from instruction Y two iterations ago (fed by two phis), the pipeliner doesn't consider Y when calculating the EarlyStart and LateStart parameters.

For example:

%phi1 = phi ..., %y
%phi2 = phi ..., %1

%x = instruction_x(%phi2)
%y = instruction_y

When scheduling we have two cases:

  1. instruction_x is scheduled before instruction_y, say at cycle x.
    Then the calculation should be as follows:
    LateStart= min(LateStart, x + NumPhis * II - Latency_Of_x)

  2. instruction_y is scheduled before instruction_x, say at cycle y.
    Then the calculation should be as follows:
    EarlyStart= max(EarlyStart, y - NumPhis * II + Latency_Of_x)

Reproducer:
https://godbolt.org/z/r1c6bTd6v

II=7
Inst (16) %11:gprc = ADDI %30:gprc_and_gprc_nor0, 4
is scheduled at cycle 10.
Whereas,
Inst (8) %25:gprc = ADD4 %4:gprc, %23:gprc
is scheduled at cycle 4.
which is an invalid schedule.

Explanation:
Inst (8) needs the output of Inst(16) from 1 iteration ago.
This means that at cycle 4 + II = 11, Inst(16)'s output should be ready to use by the next ADD4.
Inst (16) only started at cycle 10 and has a latency of 2, this means that its output won't be ready at cycle 11.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions