Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 27b9a9d

Browse files
authored
Merge pull request #3808 from WalterBright/simdExample
add clarifying examples of SIMD usage
2 parents d20bb68 + b567075 commit 27b9a9d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/core/simd.d

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,28 @@ version (D_SIMD)
409409
* op2 = second operand
410410
* Returns:
411411
* result of opcode
412+
* Example:
413+
---
414+
import core.simd;
415+
import core.stdc.stdio;
416+
417+
void main()
418+
{
419+
float4 A = [2.34f, -70000.0f, 0.00001f, 345.5f];
420+
float4 R = A;
421+
R = cast(float4) __simd(XMM.RCPSS, R, A);
422+
printf("%g %g %g %g\n", R.array[0], R.array[1], R.array[2], R.array[3]);
423+
}
424+
---
425+
* Prints `0.427368 -70000 1e-05 345.5`.
426+
* The use of the two operand form for `XMM.RCPSS` is necessary because the result of the instruction
427+
* contains elements of both operands.
428+
* Example:
429+
---
430+
double[2] A = [56.0, -75.0];
431+
double2 R = cast(double2) __simd(XMM.LODUPD, *cast(double2*)A.ptr);
432+
---
433+
* The cast to `double2*` is necessary because the type of `*A.ptr` is `double`.
412434
*/
413435
pure @safe void16 __simd(XMM opcode, void16 op1, void16 op2);
414436

0 commit comments

Comments
 (0)