[PATCH] D24153: Add bunch of _Interlocked builtins
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 7 09:56:17 PDT 2016
rnk added a comment.
Looks good to me. David, do you remember any subtleties here? I seem to recall there were some bugs in our intrin.h implementations, or inconsistencies between us and MSVC.
================
Comment at: test/CodeGen/ms-intrinsics.c:297
@@ +296,3 @@
+// CHECK: define{{.*}}i16 @test_InterlockedIncrement16(i16*{{[a-z_ ]*}}%Addend){{.*}}{
+// CHECK: [[TMP:%[0-9]+]] = atomicrmw volatile add i16* %Addend, i16 1 seq_cst
+// CHECK: [[RESULT:%[0-9]+]] = add i16 [[TMP]], 1
----------------
I think we should make these increments and decrements non-volatile. I'd like us to be able to optimize this kind of code to return 2:
int f() {
int x = 0;
_InterlockedIncrement(&x);
_InterlockedIncrement(&x);
return x; // always 2
}
https://reviews.llvm.org/D24153
More information about the cfe-commits
mailing list