This is an archive of the discontinued LLVM Phabricator instance.

[x86] Handle more cases where we can re-use an atomic operation's flags rather than doing a separate comparison.
ClosedPublic

Authored by chandlerc on Aug 20 2017, 7:15 PM.

Details

Summary

This both saves an explicit comparision and avoids the use of xadd
which introduces register constraints and other challenges to the
generated code.

The motivating case is from atomic reference counts where 1 is the
sentinel rather than 0 for whatever reason. This can and should be
lowered efficiently on x86 by just using a different flag, however the
x86 code only handled the 0 case.

There remains some further opportunities here that are currently hidden
due to canonicalization. I've included test cases that show these and
FIXMEs. However, I don't at the moment have any production use cases and
they seem substantially harder to address.

Event Timeline

chandlerc created this revision.Aug 20 2017, 7:15 PM
This revision is now accepted and ready to land.Aug 20 2017, 11:03 PM
This revision was automatically updated to reflect the committed changes.