blob: caaab3ca4f846c15954d81ad7ebe908a55d22bdb [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
2
3float fff(float x, float y) {
4// CHECK-LABEL: define float @_Z3fffff{{.*}}
5// CHECK: entry
6#pragma float_control(except, on)
7 float z;
8 z = z * z;
9 //CHECK: llvm.experimental.constrained.fmul{{.*}}
10 {
11 z = x * y;
12 //CHECK: llvm.experimental.constrained.fmul{{.*}}
13 }
14 {
15// This pragma has no effect since if there are any fp intrin in the
16// function then all the operations need to be fp intrin
17#pragma float_control(except, off)
18 z = z + x * y;
19 //CHECK: llvm.experimental.constrained.fmul{{.*}}
20 }
21 z = z * z;
22 //CHECK: llvm.experimental.constrained.fmul{{.*}}
23 return z;
24}
25float check_precise(float x, float y) {
26 // CHECK-LABEL: define float @_Z13check_preciseff{{.*}}
27 float z;
28 {
29#pragma float_control(precise, on)
30 z = x * y + z;
31 //CHECK: llvm.fmuladd{{.*}}
32 }
33 {
34#pragma float_control(precise, off)
35 z = x * y + z;
36 //CHECK: fmul fast float
37 //CHECK: fadd fast float
38 }
39 return z;
40}
41float fma_test1(float a, float b, float c) {
42// CHECK-LABEL define float @_Z9fma_test1fff{{.*}}
43#pragma float_control(precise, on)
44 float x = a * b + c;
45 //CHECK: fmuladd
46 return x;
47}