xref: /llvm-project/clang/test/CodeGen/fpconstrained.cpp (revision f5360d4bb3376347479d86547d21b95d80be786d)
1 // RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
2 // RUN: %clang_cc1 -x c++ -ffp-contract=fast -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
3 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
4 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
5 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
6 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
7 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
8 float f0, f1, f2;
9 
10   template <class>
11   class aaaa {
12    public:
13     ~aaaa();
14     void b();
15   };
16 
17   template <class c>
18   aaaa<c>::~aaaa() { try {
19     b();
20   // CHECK-LABEL: define {{.*}}void @_ZN4aaaaIiED2Ev{{.*}}
21 
22   } catch (...) {
23     // MAYTRAP: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
24     // EXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
25     // FPMODELSTRICT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
26     // STRICTEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
27     // STRICTNOEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.ignore")
28     // PRECISE: fadd contract float %{{.*}}, %{{.*}}
29     // FAST: fadd fast
30     // FASTNOCONTRACT: fadd reassoc nnan ninf nsz arcp afn float
31     f0 = f1 + f2;
32 
33     // CHECK: ret void
34   }
35   }
36 
37   class d {
38    public:
39     d(const char *, int);
40     aaaa<int> e;
41   };
42 
43 float foo() {
44   d x("", 1);
45   aaaa<int> a;
46   return f0;
47 }
48 
49