mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 01:20:51 +03:00
21 lines
487 B
D
21 lines
487 B
D
// Test vectorized fused multiply-add in a simple dot product routine
|
|
|
|
// REQUIRES: target_X86
|
|
|
|
// RUN: %ldc -mtriple=x86_64-linux-gnu -mattr=+fma -O3 -release -c -output-s -of=%t.s %s && FileCheck %s --check-prefix ASM < %t.s
|
|
|
|
import ldc.attributes;
|
|
|
|
// ASM-LABEL: dot:
|
|
@fastmath
|
|
extern (C) double dot(double[] a, double[] b)
|
|
{
|
|
double s = 0;
|
|
// ASM: vfmadd{{[123][123][123]}}pd
|
|
foreach (size_t i; 0 .. a.length)
|
|
{
|
|
s += a[i] * b[i];
|
|
}
|
|
return s;
|
|
// ASM: ret
|
|
}
|