[PATCH] D31736: Implement _interlockedbittestandset as a builtin

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 6 13:37:02 PDT 2017


hans added inline comments.


================
Comment at: lib/CodeGen/CGBuiltin.cpp:570
+        llvm::AtomicOrdering::SequentiallyConsistent);
+    llvm::Value *Shifted = Builder.CreateLShr(RMWI, Bit);
+    llvm::Value *Truncated =
----------------
rnk wrote:
> 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?
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.


https://reviews.llvm.org/D31736





More information about the cfe-commits mailing list