LDC 1.5-1.6 huge degradation of optimization

Johan Engelen j at j.nl
Thu Nov 30 08:56:31 UTC 2017


On Monday, 27 November 2017 at 10:41:44 UTC, Igor Shirkalin wrote:
> Hello!
>
> I have found that LDC1.5-1.6 generate unoptimized code in 
> contrast to LDC1.3-1.4 in some cases. I tried to extract the 
> example and make it as short as possible. The goal is to get 
> the compiled code with avx(2) instructions.

This will need a lot more investigation to figure out what is 
going wrong. It could be that the optimization pipeline set up by 
LDC needs to be adjusted for newer LLVM versions, or that extra 
annotations are needed.
Some notes:
- It's strange that adding the calculation of `sum` leads to an 
overall more optimized output with AVX2 instructions (good that 
you found out about that!).
- It would help if you find a C/C++ equivalent to show the 
problem to LLVM devs (gcc.godbolt.org has all relevant LLVM/Clang 
versions)
- The optimization is fragile also in LDC 1.4: manual unrolling 
of the inner loop somehow removes the AVX2 optimizations. 
https://godbolt.org/g/NF3eHf  Did I make a mistake?

-Johan



More information about the digitalmars-d-ldc mailing list