xref: /llvm-project/clang/test/CodeGen/fpconstrained.cpp (revision 2b35511350454dd22997f129ee529e3fdb129ac2)
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 
9 // Disabled until constrained floating point is completed for PowerPC.
10 // XFAIL: powerpc, powerpc64, powerpc64le
11 
12 float f0, f1, f2;
13 
14   template <class>
15   class aaaa {
16    public:
17     ~aaaa();
18     void b();
19   };
20 
21   template <class c>
22   aaaa<c>::~aaaa() { try {
23     b();
24   // CHECK-LABEL: define {{.*}}void @_ZN4aaaaIiED2Ev{{.*}}
25 
26   } catch (...) {
27     // MAYTRAP: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
28     // EXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
29     // FPMODELSTRICT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
30     // STRICTEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
31     // STRICTNOEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.ignore")
32     // PRECISE: fadd contract float %{{.*}}, %{{.*}}
33     // FAST: fadd fast
34     // FASTNOCONTRACT: fadd reassoc nnan ninf nsz arcp afn float
35     f0 = f1 + f2;
36 
37     // CHECK: ret void
38   }
39   }
40 
41   class d {
42    public:
43     d(const char *, int);
44     aaaa<int> e;
45   };
46 
47 float foo() {
48   d x("", 1);
49   aaaa<int> a;
50   return f0;
51 }
52 
53