SIMD under LDC

Igor via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 6 02:01:18 PDT 2017


On Tuesday, 5 September 2017 at 18:50:34 UTC, Johan Engelen wrote:
> On Monday, 4 September 2017 at 20:39:11 UTC, Igor wrote:
>> I found that I can't use __simd function from core.simd under 
>> LDC and that it has ldc.simd but I couldn't find how to 
>> implement equivalent to this with it:
>>
>> ubyte16* masks = ...;
>> foreach (ref c; pixels) {
>> 	c = __simd(XMM.PSHUFB, c, *masks);
>> }
>>
>> I see it has shufflevector function but it only accepts 
>> constant masks and I am using a variable one. Is this possible 
>> under LDC?
>
> You can use the module ldc.gccbuiltins_x86.di, 
> __builtin_ia32_pshufb128 and __builtin_ia32_pshufb256.
>
> (also see 
> https://gcc.gnu.org/onlinedocs/gcc-4.4.5/gcc/X86-Built_002din-Functions.html)
>
> Please file a feature request about shufflevector with variable 
> mask in our (LDC) issue tracker on Github; with some code that 
> you'd expect to work. Thanks.
>
> - Johan

I'll try that this evening. Thanks! I'll also open an issue but 
are you sure such feature request is valid since LLVM 
shufflevector instruction, as far as I see, only supports 
constant masks as well.


More information about the Digitalmars-d-learn mailing list