File: attr_llvmFMF_contract.d

package info (click to toggle)
ldc 1%3A1.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,248 kB
  • sloc: cpp: 61,598; ansic: 14,545; sh: 1,014; makefile: 972; asm: 510; objc: 135; exp: 48; python: 12
file content (20 lines) | stat: -rw-r--r-- 711 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Tests the @ldc.attributes.llvmFastMathFlag("contract") UDA
// Also tests that adding this attribute indeed leads to LLVM optimizing it to a fused multiply-add for a simple case.

// REQUIRES: target_X86

// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s --check-prefix LLVM < %t.ll
// RUN: %ldc -betterC -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;

// LLVM-LABEL: define{{.*}} @{{.*}}contract
// ASM-LABEL: contract:
@llvmFastMathFlag("contract")
extern(C) double contract(double a, double b, double c)
{
// LLVM: fmul contract double
// LLVM: fadd contract double
// ASM: vfmadd
    return a * b + c;
}