blob: 773cfcdd28299ebbe9f3e0e2d4c358911a50a524 [file] [log] [blame]
Melanie Blowerf5360d42020-05-01 10:32:06 -07001// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
Melanie Blowere5578012020-05-06 11:45:55 -07002// RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
Melanie Blowerf5360d42020-05-01 10:32:06 -07003
4float fff(float x, float y) {
5// CHECK-LABEL: define float @_Z3fffff{{.*}}
6// CHECK: entry
7#pragma float_control(except, on)
8 float z;
9 z = z * z;
10 //CHECK: llvm.experimental.constrained.fmul{{.*}}
11 {
12 z = x * y;
13 //CHECK: llvm.experimental.constrained.fmul{{.*}}
14 }
15 {
16// This pragma has no effect since if there are any fp intrin in the
17// function then all the operations need to be fp intrin
18#pragma float_control(except, off)
19 z = z + x * y;
20 //CHECK: llvm.experimental.constrained.fmul{{.*}}
21 }
22 z = z * z;
23 //CHECK: llvm.experimental.constrained.fmul{{.*}}
24 return z;
25}
26float check_precise(float x, float y) {
27 // CHECK-LABEL: define float @_Z13check_preciseff{{.*}}
28 float z;
29 {
30#pragma float_control(precise, on)
31 z = x * y + z;
32 //CHECK: llvm.fmuladd{{.*}}
33 }
34 {
35#pragma float_control(precise, off)
36 z = x * y + z;
37 //CHECK: fmul fast float
38 //CHECK: fadd fast float
39 }
40 return z;
41}
Melanie Blowere5578012020-05-06 11:45:55 -070042
Melanie Blowerf5360d42020-05-01 10:32:06 -070043float fma_test1(float a, float b, float c) {
44// CHECK-LABEL define float @_Z9fma_test1fff{{.*}}
45#pragma float_control(precise, on)
46 float x = a * b + c;
47 //CHECK: fmuladd
48 return x;
49}
Melanie Blowere5578012020-05-06 11:45:55 -070050
51#if FENV_ON
52// expected-warning@+1{{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
53#pragma STDC FENV_ACCESS ON
54#endif
55// CHECK-LABEL: define {{.*}}callt{{.*}}
56
57void callt() {
58 volatile float z;
59 z = z * z;
60//CHECK: = fmul float
61}