This is an archive of the discontinued LLVM Phabricator instance.

[MachineScheduler] Don't enforce some hazard checks pre-RA.
Needs ReviewPublic

Authored by jonpa on May 15 2018, 4:28 AM.

Details

Summary

Currently, SchedBoundary::checkHazard() checks if an instruction begins or ends a group and if its micro-ops fits in the current group and may decide to put SU into Pending instead of Available based on this.

These are exact checks, but since so many things can happen with the code between pre-RA scheduling and final output, it seems far-fetched to put a priority pre-RA on this. It seems better to let such an instruction into Available and pick it if it e.g. helps with register pressure, and trust that post-RA scheduling will fix the grouping (which it most likely has to do anyway).

This patch introduces a new member SchedBoundary::IsPostRA and uses this to only do these checks post regalloc.

I also removed a TODO comment which seems already done.

This will be committed along with SystemZ changes soon, hopefully.

Diff Detail

Event Timeline

jonpa created this revision.May 15 2018, 4:28 AM
jonpa added a comment.May 15 2018, 4:37 AM

Forgot to mention that as of now ~20 X86 tests fail, and also a few others.

javed.absar added inline comments.May 15 2018, 5:08 AM
lib/CodeGen/MachineScheduler.cpp
2256

Probably the comment here needs updating if we are going to change behaviour.
There is another problem -
"Single Issue " relies on BeginGroup/EndGroup and that is not just PostRA related.

jonpa added inline comments.May 15 2018, 6:40 AM
lib/CodeGen/MachineScheduler.cpp
2256

So, with our abstract machine as a model, what specifically does "Single Issue" imply? Is this on a particular target?

To me this sounds like such an instruction should have a doubled value of NumMicroOps, which then pushes CurrCycle further. Per the basic premise of this patch, I would have hoped this is good enough pre-RA. Why not?

Would it help to also guard this change so that only targets that do post-RA scheduling is affected?

jonpa updated this revision to Diff 148880.May 29 2018, 4:21 AM

Patch updated so that the checks are done post-RA or pre-RA if target does not do post-RA scheduling. Now only two tests fail.

The ARM test seem to have tested that the cycle is bumped based on BeginGroup/EndGroup flags, which does not now happen.
The SystemZ test now contains one more spill, but I am hoping this disappears once the other scheduling patch for SystemZ also is applied.

On SystemZ, those instructions are quite rare, so it is typically possible to rearrange them post-RA in a constructive way while ignoring them pre-RA. Is this not true on ARM (or other targets)?

Does this patch make sense now? If not, could we add a target flag to control this?

jonpa added a comment.Jul 24 2018, 4:31 AM

ping!

Still does not make sense to me to have hard checks for decoding constraints pre-RA if the target also does post-RA scheduling... Is this generally true, or would this have to wait for the day that SystemZ might get its own pre-RA sched strategy?