File: attr_llvmFMF_contract.d

package info (click to toggle)
ldc 1%3A1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 80,880 kB
  • sloc: ansic: 123,899; cpp: 84,038; sh: 1,402; makefile: 1,083; asm: 919; objc: 65; exp: 30; python: 22
file content (20 lines) | stat: -rw-r--r-- 728 bytes parent folder | download
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: atleast_llvm500, 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;
}