blob: 09d249d6c2cb252ebbb6661fc5e6788fc95060c4 [file] [log] [blame]
Chandler Carruthabf07a72012-01-02 14:19:45 +00001// Test that the GCC fast-math floating point flags get lowered to the correct
2// permutation of Clang frontend flags. This is non-trivial for a few reasons.
3// First, the GCC flags have many different and surprising effects. Second,
4// LLVM only supports three switches which is more coarse grained than GCC's
5// support.
6//
NAKAMURA Takumiba82a612012-04-27 04:36:27 +00007// Both of them use gcc driver for as.
8// XFAIL: cygwin,mingw32
9//
Chandler Carruthabf07a72012-01-02 14:19:45 +000010// RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \
11// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
12// CHECK-NO-INFS: "-cc1"
13// CHECK-NO-INFS: "-menable-no-infs"
14//
15// RUN: %clang -### -fno-honor-nans -c %s 2>&1 \
16// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
17// CHECK-NO-NANS: "-cc1"
18// CHECK-NO-NANS: "-menable-no-nans"
19//
20// RUN: %clang -### -fmath-errno -c %s 2>&1 \
21// RUN: | FileCheck --check-prefix=CHECK-MATH-ERRNO %s
22// CHECK-MATH-ERRNO: "-cc1"
23// CHECK-MATH-ERRNO: "-fmath-errno"
24//
Chandler Carruth4f50c502012-04-26 02:10:51 +000025// RUN: %clang -### -fmath-errno -fno-math-errno -c %s 2>&1 \
26// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
27// RUN: %clang -### -target i686-apple-darwin -c %s 2>&1 \
28// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
29// CHECK-NO-MATH-ERRNO: "-cc1"
30// CHECK-NO-MATH-ERRNO-NOT: "-fmath-errno"
31//
32// RUN: %clang -### -fno-math-errno -fassociative-math -freciprocal-math \
33// RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \
Chandler Carruthabf07a72012-01-02 14:19:45 +000034// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
35// CHECK-UNSAFE-MATH: "-cc1"
36// CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math"
37//
38// Check that various umbrella flags also enable these frontend options.
39// RUN: %clang -### -ffast-math -c %s 2>&1 \
40// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
41// RUN: %clang -### -ffast-math -c %s 2>&1 \
42// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
43// RUN: %clang -### -ffast-math -c %s 2>&1 \
44// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
45// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
46// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
47// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
48// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
Chandler Carruth4f50c502012-04-26 02:10:51 +000049// RUN: %clang -### -funsafe-math-optimizations -fno-math-errno -c %s 2>&1 \
Chandler Carruthabf07a72012-01-02 14:19:45 +000050// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
51//
52// One umbrella flag is *really* weird and also changes the semantics of the
53// program by adding a special preprocessor macro. Check that the frontend flag
54// modeling this semantic change is provided. Also check that the semantic
55// impact remains even if every optimization is disabled.
56// RUN: %clang -### -ffast-math -c %s 2>&1 \
57// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
58// RUN: %clang -### -ffast-math -fno-finite-math-only \
59// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \
60// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
61// CHECK-FAST-MATH: "-cc1"
62// CHECK-FAST-MATH: "-ffast-math"
63//
64// Check various means of disabling these flags, including disabling them after
65// they've been enabled via an umbrella flag.
66// RUN: %clang -### -fno-honor-infinities -fhonor-infinities -c %s 2>&1 \
67// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
68// RUN: %clang -### -ffinite-math-only -fhonor-infinities -c %s 2>&1 \
69// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
70// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
71// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
72// RUN: %clang -### -ffast-math -fhonor-infinities -c %s 2>&1 \
73// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
74// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
75// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
76// CHECK-NO-NO-INFS: "-cc1"
77// CHECK-NO-NO-INFS-NOT: "-menable-no-infs"
78// CHECK-NO-NO-INFS: "-o"
79//
80// RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \
81// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
82// RUN: %clang -### -ffinite-math-only -fhonor-nans -c %s 2>&1 \
83// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
84// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
85// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
86// RUN: %clang -### -ffast-math -fhonor-nans -c %s 2>&1 \
87// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
88// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
89// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
90// CHECK-NO-NO-NANS: "-cc1"
91// CHECK-NO-NO-NANS-NOT: "-menable-no-nans"
92// CHECK-NO-NO-NANS: "-o"
93//
94// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
95// RUN: -fno-trapping-math -fno-associative-math -c %s 2>&1 \
96// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
97// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
98// RUN: -fno-trapping-math -fno-reciprocal-math -c %s 2>&1 \
99// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
100// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
101// RUN: -fno-trapping-math -fsigned-zeros -c %s 2>&1 \
102// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
103// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
104// RUN: -fno-trapping-math -ftrapping-math -c %s 2>&1 \
105// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
106// RUN: %clang -### -funsafe-math-optimizations -fno-associative-math -c %s \
107// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
108// RUN: %clang -### -funsafe-math-optimizations -fno-reciprocal-math -c %s \
109// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
110// RUN: %clang -### -funsafe-math-optimizations -fsigned-zeros -c %s 2>&1 \
111// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
112// RUN: %clang -### -funsafe-math-optimizations -ftrapping-math -c %s 2>&1 \
113// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
114// RUN: %clang -### -funsafe-math-optimizations -fno-unsafe-math-optimizations \
115// RUN: -c %s 2>&1 \
116// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
117// RUN: %clang -### -ffast-math -fno-associative-math -c %s 2>&1 \
118// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
119// RUN: %clang -### -ffast-math -fno-reciprocal-math -c %s 2>&1 \
120// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
121// RUN: %clang -### -ffast-math -fsigned-zeros -c %s 2>&1 \
122// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
123// RUN: %clang -### -ffast-math -ftrapping-math -c %s 2>&1 \
124// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
125// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \
126// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
127// CHECK-NO-UNSAFE-MATH: "-cc1"
128// CHECK-NO-UNSAFE-MATH-NOT: "-menable-unsafe-fp-math"
129// CHECK-NO-UNSAFE-MATH: "-o"