[LLVMdev] Why can't atomic loads and stores handle floats?
Filip Pizlo
fpizlo at apple.com
Sat May 24 15:18:57 PDT 2014
What is the downside of the currently generated IR? There ain't nothin' wrong with bitcasts, IMO.
-Filip
> On May 24, 2014, at 2:17 PM, Philip Reames <listmail at philipreames.com> wrote:
>
> Looking through the documentation, I discovered that atomic loads and stores are only supported for integer types. Can anyone provide some background on this? Why is this true?
>
> Currently, given code:
> std::atomic<float> aFloat;
> void foo() {
> float f = atomic_load(&aFloat);
> ..
> }
>
> Clang generates code like:
> %"struct.std::atomic.2" = type { float }
> @aFloat = global %"struct.std::atomic.2" zeroinitializer, align 4
>
> define void @foo() {
> %1 = load atomic i32* bitcast (%"struct.std::atomic.2"* @aFloat to i32*) seq_cst, align 4
> %2 = bitcast i32 %1 to float
> ...
> }
>
> This seems less than ideal. I would expect that we might have to desugar floats into integer & cast operations in the backend, but why is this imposed on the frontend?
>
> More generally, is there anyone who is knowledgeable and/or working on atomics and synchronization in LLVM? I've got a number of questions w.r.t. semantics and have found a number of what I believe to be missed optimizations. I'm happy to file the later, but I'd like to talk them over with a knowledgeable party first.
>
> Philip
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140524/2e259708/attachment.html>
More information about the llvm-dev
mailing list