__simd

Generate two operand instruction with XMM 128 bit operands.

This is a compiler magic function - it doesn't behave like regular D functions.

  1. void16 __simd(XMM opcode, void16 op1, void16 op2)
    version(D_SIMD)
    pure nothrow @safe @nogc pure @safe
    void16
    __simd
    (,
    void16 op1
    ,
    void16 op2
    )
  2. void16 __simd(XMM opcode, void16 op1)
  3. void16 __simd(XMM opcode, void16 op1, void16 op2, ubyte imm8)

Parameters

opcode XMM

any of the XMM opcodes; it must be a compile time constant

op1 void16

first operand

op2 void16

second operand

Return Value

Type: void16

result of opcode

Examples

import core.simd;
import core.stdc.stdio;

void main()
{
    float4 A = [2.34f, -70000.0f, 0.00001f, 345.5f];
    float4 R = A;
    R = cast(float4) __simd(XMM.RCPSS, R, A);
    printf("%g %g %g %g\n", R.array[0], R.array[1], R.array[2], R.array[3]);
}

Prints 0.427368 -70000 1e-05 345.5. The use of the two operand form for XMM.RCPSS is necessary because the result of the instruction contains elements of both operands.

double[2] A = [56.0, -75.0];
double2 R = cast(double2) __simd(XMM.LODUPD, *cast(double2*)A.ptr);

The cast to double2* is necessary because the type of *A.ptr is double.

float4 a;
a = cast(float4)__simd(XMM.PXOR, a, a);

Meta