Memory legalizer, waitcnt, and shrink passes can perturb the instructions, which means that the post-RA hazard recognizer pass should run after them. Otherwise, one of those passes may invalidate the work done by the hazard recognizer. Note that this has adverse side-effect that any consecutive S_NOP 0's, emitted by the hazard recognizer, will not be shrunk into a single S_NOP <N>. This should be addressed in a follow-on patch.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | ||
---|---|---|
902 ↗ | (On Diff #155348) | I'm surprised we run shrink after this point. I think this can plausibly be an issue. The immediate materialize would eliminate a wait state that wasn't necessary, but now is since the copy is eliminated. I think in practice the shrink pass isn't very good at folding immediates post-RA, if it even tries |
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | ||
---|---|---|
902 ↗ | (On Diff #155348) | I will move the hazard recognizer after shrink instructions, unless you're suggesting that the shrink pass be moved somewhere else? I think that moving the hazard recognizer after the shrink pass has the side-effect that some S_NOP 0's won't be collapsed into, say S_NOP <N>. The hazard recognizer just creates individual S_NOP 0 instrs and is relying on the shrink pass to turn them into S_NOP <N>. I suppose the hazard recognizer could be enhanced to generate the S_NOP <N> instrs on its own. |
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | ||
---|---|---|
902 ↗ | (On Diff #155348) | Yes, the hazard recognizer ideally would do that. The shrink pass deals with this as a workaround for it seeming to assume all nops are the same. It's probably OK to leave as-is for now |
lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | ||
---|---|---|
902 ↗ | (On Diff #155348) | I would move shrink before hazard recognizer. |