How use ldc pragmas?

james.p.leblanc james.p.leblanc at gmail.com
Fri Oct 1 19:23:06 UTC 2021


D-ers,

After experimenting with ldc's autovectorization of avx code, it 
appears there may
be counter-intuitiveness to the autovectorization (especially for 
complex numbers).
(My comment may be wrong, so any corrections are quite welcome).

Based on this, I wanted to investigate the use of ldc's pragma 
capabilities
(as found in ldc2/import/gccbuiltins_x86.di).

However, getting the ball rolling is a bit difficult, as I have 
not found a
simple example showing the whole process.  What I have just now 
is:

```d
// my example.d
import std.stdio;
import ldc.intrinsics;

void main()
{
    writeln("hello");

    float x;

    pragma(LDC_intrinsic, "llvm.sqrt.32")
    float sqrt(float);
}
```
I try to compile the above using:

```bash
ldc2 -mattr=+avx2 myexample.d -H 
~/ldc2/import/ldc/gccbuiltins_x86.di
```

But receive the following:
```console
ldcint.d(11): Error: unrecognized `pragma(LDC_intrinsic)`
```

I get the feeling that I am really "lost in the woods" here, 
probably
missing important aspects.

Are there any pointers this forum might have to help here?
(A very simple and complete example would be greatly appreciated!)

Thanks!
James



More information about the Digitalmars-d-learn mailing list