-
-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T.init on arrays unrolls initialisation loop #119
Comments
Yes, I noticed this as well. When building with optimizations enabled, LLVM recognizes the »loop« and replaces it with a For codegen speed, it might still be beneficial to emit less IR instructions, though. |
The memset vs loop performance is probably comparable, but what about the |
The codegen could (and should) definitely be improved, no question. Should not be too hard, although I'd regard it as a rather low-priority item compared to the other open bugs. I can't judge the performance characteristics of what DMD currently emits without detailed benchmarking, but I suppose the size of the generated code alone is reason enough to report an upstream issue. |
I looked into this. The loop unrolling is in method |
Instead of creating individual stores to the array elements an constant array is created and assigned to the destination memory. This is much less IR than before. With -O it is optimized to a memset.
Instead of creating individual stores to the array elements an constant array is created and assigned to the destination memory. This is much less IR than before. With -O it is optimized to a memset.
Instead of creating individual stores to the array elements an constant array is created and assigned to the destination memory. This is much less IR than before. With -O it is optimized to a memset.
Instead of creating individual stores to the array elements an constant array is created and assigned to the destination memory. This is much less IR than before. With -O it is optimized to a memset.
Instead of creating individual stores to the array elements an constant array is created and assigned to the destination memory. This is much less IR than before. With -O it is optimized to a memset.
Instead of creating individual stores to the array elements an constant array is created and assigned to the destination memory. This is much less IR than before. With -O it is optimized to a memset.
Instead of creating individual stores to the array elements an constant array is created and assigned to the destination memory. This is much less IR than before. With -O it is optimized to a memset.
Turned out to be a bit more demanding than expected. This should work in other cases, too. It looks like that there is a similar issue in method |
As a side effect, this fixed the |
add back functions used in some Windows DLLs
If we have code like:
then in LLVM, initialisation using the value 0 uses straight
@llvm.memset
, and alternatively when using a value other than 0 it uses a loop calledarrayinit
.However, the
.init
unrolls the loop into 4096 llvm stores.Looking at the assembly generated by DMD 2.059 (64-bit) on OSX, it seems to do the same thing i.e. generate 4096 movb instructions, or 512 movq if
-O
ptimized, but it seems to me that this behavior is inefficient and should be changed to use a memset with the element's init / loop.The text was updated successfully, but these errors were encountered: