This is an archive of the discontinued LLVM Phabricator instance.

Implement _interlockedbittestandset as a builtin
ClosedPublic

Authored by hans on Apr 5 2017, 4:45 PM.

Details

Summary

It's used by MS headers in VS 2017 without including intrin.h, so we can't implement it in the header anymore.

Diff Detail

Repository
rL LLVM

Event Timeline

hans created this revision.Apr 5 2017, 4:45 PM
rnk added inline comments.Apr 5 2017, 5:47 PM
lib/CodeGen/CGBuiltin.cpp
570 ↗(On Diff #94305)

Can you comment that this shifts the relevant bit into the low bit, truncates to i8, and then tests the low bit? At first I was thinking "of course, we just do AND %old, $constant to test the bit".

Do we successfully pattern match this idiom to lock bts? Is there a pattern match we should target?

hans updated this revision to Diff 94433.Apr 6 2017, 1:36 PM

Add comment.

lib/CodeGen/CGBuiltin.cpp
570 ↗(On Diff #94305)

Added the comment.

No, we generate horrible code for this, but it's the same as we did for the inline version in intrin.h. We have BTS instructions in the .td file, but no patterns for them.

I thought a bit about adding a pattern match for this, but I'm not sure it would be worth the effort.

rnk accepted this revision.Apr 6 2017, 4:07 PM

lgtm

lib/CodeGen/CGBuiltin.cpp
570 ↗(On Diff #94305)

Let's file a bug for it and call it a day.

This revision is now accepted and ready to land.Apr 6 2017, 4:07 PM
This revision was automatically updated to reflect the committed changes.