This is an archive of the discontinued LLVM Phabricator instance.

[X86] Mark EMMS and FEMMS as clobbering MM0-7 and ST0-7.
ClosedPublic

Authored by craig.topper on Jan 26 2019, 9:42 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jan 26 2019, 9:42 PM

I guess this is fine; we do technically need to clobber MM* when we see emms, in case someone writes an emms between two MMX operations. But this doesn't solve the related issues with pre-RA scheduling or IR code movement, though, so I'd hesitate to say this fixes PR35982.

It's unfortunate that emms is so slow on Intel processors that it's impractical to insert automatically like we do for vzeroupper.

Agreed, I wouldn't close the bug for this. But it gets us closer to generating not broken code for more cases with low effort.

How can we fix the IR code movement issue?

Assuming we don't insert emms implicitly, I'm not sure how to express the restriction at the IR level.

We could try to model the FP status register as "memory", somehow, and say every MMX operation writes to it, by marking them inaccessiblememonly or something like that. But it's not clear how you model the interaction between that, and FP operations which we don't model as reading/writing memory. Granted, if your MMX-using function doesn't contain any values of floating-point type, the result would mostly work in practice.

Can we approve this patch? I'll leave the bugzilla open. I'll also try to find out if we have any other failing tests internally that might be hitting the pre-RA or IR issue. I know we have other scheduling related bug arounds FP

This revision is now accepted and ready to land.Jan 30 2019, 11:09 AM
This revision was automatically updated to reflect the committed changes.