This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Skip pseudo MIs in hazard recognizer
ClosedPublic

Authored by cdevadas on Aug 13 2021, 2:12 AM.

Details

Summary

Instructions like WAVE_BARRIER and SI_MASKED_UNREACHABLE
are only placeholders to prevent certain unwanted
transformations and will get discarded during assembly emission.
They should not be counted during nop insertion.

Diff Detail

Event Timeline

cdevadas created this revision.Aug 13 2021, 2:12 AM
cdevadas requested review of this revision.Aug 13 2021, 2:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2021, 2:12 AM

I think you're missing the check in AdvanceCycle

I think you're missing the check in AdvanceCycle

There was a call to getNumWaitStates in AdvanceCycle. I presumed a zero waitstate here is equivalent to an early return.
Isn't it?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L365

I think you're missing the check in AdvanceCycle

There was a call to getNumWaitStates in AdvanceCycle. I presumed a zero waitstate here is equivalent to an early return.
Isn't it?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L365

I think the early return on isMetaInstruction avoids pushing the instruction into EmittedInstrs

I think you're missing the check in AdvanceCycle

There was a call to getNumWaitStates in AdvanceCycle. I presumed a zero waitstate here is equivalent to an early return.
Isn't it?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L365

I think the early return on isMetaInstruction avoids pushing the instruction into EmittedInstrs

I think AdvanceCycle shall do the same as with isMetaInstruction() if getNumWaitStates() returned 0.

I think you're missing the check in AdvanceCycle

There was a call to getNumWaitStates in AdvanceCycle. I presumed a zero waitstate here is equivalent to an early return.
Isn't it?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L365

I think the early return on isMetaInstruction avoids pushing the instruction into EmittedInstrs

I think AdvanceCycle shall do the same as with isMetaInstruction() if getNumWaitStates() returned 0.

The AdvanceCycle will be called by both Post-RA scheduler and hazard recognizer. I am beginning to think that the early return is necessary to prevent adding it into EmittedInstrs.
Alternatively, how about return early when NumWaitStates is zero?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L366

I think you're missing the check in AdvanceCycle

There was a call to getNumWaitStates in AdvanceCycle. I presumed a zero waitstate here is equivalent to an early return.
Isn't it?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L365

I think the early return on isMetaInstruction avoids pushing the instruction into EmittedInstrs

I think AdvanceCycle shall do the same as with isMetaInstruction() if getNumWaitStates() returned 0.

The AdvanceCycle will be called by both Post-RA scheduler and hazard recognizer. I am beginning to think that the early return is necessary to prevent adding it into EmittedInstrs.
Alternatively, how about return early when NumWaitStates is zero?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L366

That's what I mean by "I think AdvanceCycle shall do the same as with isMetaInstruction() if getNumWaitStates() returned 0."

I think you're missing the check in AdvanceCycle

There was a call to getNumWaitStates in AdvanceCycle. I presumed a zero waitstate here is equivalent to an early return.
Isn't it?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L365

I think the early return on isMetaInstruction avoids pushing the instruction into EmittedInstrs

I think AdvanceCycle shall do the same as with isMetaInstruction() if getNumWaitStates() returned 0.

The AdvanceCycle will be called by both Post-RA scheduler and hazard recognizer. I am beginning to think that the early return is necessary to prevent adding it into EmittedInstrs.
Alternatively, how about return early when NumWaitStates is zero?
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp#L366

Right, it matters in the post-RA scheduler. For example, if you replace the KILL with WAVE_BARRIER in the test hazard-kill.mir, the scheduler doesn't see the hazard.

cdevadas updated this revision to Diff 366724.Aug 16 2021, 1:01 PM

Added early return from AdvanceCycle if NumWaitStates is zero.
It is required for Post-RA scheduler.

rampitec accepted this revision.Aug 16 2021, 1:04 PM

LGTM, thanks!

This revision is now accepted and ready to land.Aug 16 2021, 1:04 PM
This revision was landed with ongoing or failed builds.Aug 16 2021, 8:13 PM
This revision was automatically updated to reflect the committed changes.