File: attr_fastmath.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 (53 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Test @fastmath

// RUN: %ldc -O0 -release -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll

import ldc.attributes;

// CHECK-LABEL: define{{.*}} @notfast
// CHECK-SAME: #[[ATTR_NOTFAST:[0-9]+]]
extern (C) double notfast(double a, double b)
{
    @fastmath
    double nested_fast(double a, double b)
    {
        return a * b;
    }

// CHECK-NOT: fmul fast
    return a * b;
}
// CHECK-LABEL: define{{.*}} @{{.*}}nested_fast
// CHECK: fmul fast


// CHECK-LABEL: define{{.*}} @fast
// CHECK-SAME: #[[ATTR_FAST:[0-9]+]]
@fastmath
extern (C) double fast(double a, double b)
{
    double c;

    double nested_slow(double a, double b)
    {
        return a * b;
    }

    // Also test new scopes when generating the IR.
    try {
// CHECK: fmul fast
        c += a * b;
    }
    catch (Throwable)
    {
// CHECK: fmul fast
        return a * b;
    }
// CHECK: fmul fast
    return c + a * b;
}
// CHECK-LABEL: define{{.*}} @{{.*}}nested_slow
// CHECK-NOT: fmul fast

// CHECK-DAG: attributes #[[ATTR_FAST]] ={{.*}} "unsafe-fp-math"="true"
// CHECK-NOT: attributes #[[ATTR_NOTFAST]] ={{.*}} "unsafe-fp-math"="true"