blob: 91af2e1dce453edd67136d867f66bee17759fc93 [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.
NAKAMURA Takumi5e4ccb42012-12-11 07:06:09 +00008// REQUIRES: clang-driver
NAKAMURA Takumiba82a612012-04-27 04:36:27 +00009//
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//
Chad Rosier80ecf5e2012-09-25 22:03:25 +000015// RUN: %clang -### -fno-fast-math -fno-honor-infinities -c %s 2>&1 \
16// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH-NO-INFS %s
17// CHECK-NO-FAST-MATH-NO-INFS: "-cc1"
18// CHECK-NO-FAST-MATH-NO-INFS: "-menable-no-infs"
19//
20// RUN: %clang -### -fno-honor-infinities -fno-fast-math -c %s 2>&1 \
21// RUN: | FileCheck --check-prefix=CHECK-NO-INFS-NO-FAST-MATH %s
22// CHECK-NO-INFS-NO-FAST-MATH: "-cc1"
23// CHECK-NO-INFS-NO-FAST-MATH-NOT: "-menable-no-infs"
24//
Chandler Carruthabf07a72012-01-02 14:19:45 +000025// RUN: %clang -### -fno-honor-nans -c %s 2>&1 \
26// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
27// CHECK-NO-NANS: "-cc1"
28// CHECK-NO-NANS: "-menable-no-nans"
29//
Chad Rosier80ecf5e2012-09-25 22:03:25 +000030// RUN: %clang -### -fno-fast-math -fno-honor-nans -c %s 2>&1 \
31// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH-NO-NANS %s
32// CHECK-NO-FAST-MATH-NO-NANS: "-cc1"
33// CHECK-NO-FAST-MATH-NO-NANS: "-menable-no-nans"
34//
35// RUN: %clang -### -fno-honor-nans -fno-fast-math -c %s 2>&1 \
36// RUN: | FileCheck --check-prefix=CHECK-NO-NANS-NO-FAST-MATH %s
37// CHECK-NO-NANS-NO-FAST-MATH: "-cc1"
38// CHECK-NO-NANS-NO-FAST-MATH-NOT: "-menable-no-nans"
39//
Chandler Carruthabf07a72012-01-02 14:19:45 +000040// RUN: %clang -### -fmath-errno -c %s 2>&1 \
41// RUN: | FileCheck --check-prefix=CHECK-MATH-ERRNO %s
42// CHECK-MATH-ERRNO: "-cc1"
43// CHECK-MATH-ERRNO: "-fmath-errno"
44//
Chad Rosier80ecf5e2012-09-25 22:03:25 +000045// RUN: %clang -### -fno-fast-math -fmath-errno -c %s 2>&1 \
46// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH-MATH-ERRNO %s
47// CHECK-NO-FAST-MATH-MATH-ERRNO: "-cc1"
48// CHECK-NO-FAST-MATH-MATH-ERRNO: "-fmath-errno"
49//
50// RUN: %clang -### -fmath-errno -fno-fast-math -c %s 2>&1 \
51// RUN: | FileCheck --check-prefix=CHECK-MATH-ERRNO-NO-FAST-MATH %s
52// CHECK-MATH-ERRNO-NO-FAST-MATH: "-cc1"
53// CHECK-MATH-ERRNO-NO-FAST-MATH-NOT: "-fmath-errno"
54//
Chandler Carruth4f50c502012-04-26 02:10:51 +000055// RUN: %clang -### -fmath-errno -fno-math-errno -c %s 2>&1 \
56// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
57// RUN: %clang -### -target i686-apple-darwin -c %s 2>&1 \
58// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
Benjamin Kramer769aa2d2012-05-02 14:55:48 +000059// RUN: %clang -### -target x86_64-unknown-freebsd -c %s 2>&1 \
60// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
61// RUN: %clang -### -target x86_64-unknown-netbsd -c %s 2>&1 \
62// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
63// RUN: %clang -### -target x86_64-unknown-openbsd -c %s 2>&1 \
64// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
65// RUN: %clang -### -target x86_64-unknown-dragonfly -c %s 2>&1 \
66// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
Chandler Carruth4f50c502012-04-26 02:10:51 +000067// CHECK-NO-MATH-ERRNO: "-cc1"
68// CHECK-NO-MATH-ERRNO-NOT: "-fmath-errno"
69//
70// RUN: %clang -### -fno-math-errno -fassociative-math -freciprocal-math \
71// RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \
Chandler Carruthabf07a72012-01-02 14:19:45 +000072// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
73// CHECK-UNSAFE-MATH: "-cc1"
74// CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math"
75//
Chad Rosier80ecf5e2012-09-25 22:03:25 +000076// RUN: %clang -### -fno-fast-math -fno-math-errno -fassociative-math -freciprocal-math \
77// RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \
78// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH-UNSAFE-MATH %s
79// CHECK-NO-FAST-MATH-UNSAFE-MATH: "-cc1"
80// CHECK-NO-FAST-MATH-UNSAFE-MATH: "-menable-unsafe-fp-math"
81//
82// RUN: %clang -### -fno-fast-math -fno-math-errno -fassociative-math -freciprocal-math \
83// RUN: -fno-fast-math -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \
84// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH-NO-FAST-MATH %s
85// CHECK-UNSAFE-MATH-NO-FAST-MATH: "-cc1"
86// CHECK-UNSAFE-MATH-NO-FAST-MATH-NOT: "-menable-unsafe-fp-math"
87//
Chandler Carruthabf07a72012-01-02 14:19:45 +000088// Check that various umbrella flags also enable these frontend options.
89// RUN: %clang -### -ffast-math -c %s 2>&1 \
90// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
91// RUN: %clang -### -ffast-math -c %s 2>&1 \
92// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
93// RUN: %clang -### -ffast-math -c %s 2>&1 \
94// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
95// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
96// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
97// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
98// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
Chandler Carruth4f50c502012-04-26 02:10:51 +000099// RUN: %clang -### -funsafe-math-optimizations -fno-math-errno -c %s 2>&1 \
Chandler Carruthabf07a72012-01-02 14:19:45 +0000100// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
101//
102// One umbrella flag is *really* weird and also changes the semantics of the
103// program by adding a special preprocessor macro. Check that the frontend flag
104// modeling this semantic change is provided. Also check that the semantic
105// impact remains even if every optimization is disabled.
106// RUN: %clang -### -ffast-math -c %s 2>&1 \
107// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
Chad Rosier80ecf5e2012-09-25 22:03:25 +0000108// RUN: %clang -### -fno-fast-math -ffast-math -c %s 2>&1 \
109// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
Chandler Carruthabf07a72012-01-02 14:19:45 +0000110// RUN: %clang -### -ffast-math -fno-finite-math-only \
111// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \
112// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
113// CHECK-FAST-MATH: "-cc1"
114// CHECK-FAST-MATH: "-ffast-math"
115//
Chad Rosier80ecf5e2012-09-25 22:03:25 +0000116// RUN: %clang -### -ffast-math -fno-fast-math -c %s 2>&1 \
117// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s
118// CHECK-NO-FAST-MATH: "-cc1"
119// CHECK-NO-FAST-MATH-NOT: "-ffast-math"
120//
Chandler Carruthabf07a72012-01-02 14:19:45 +0000121// Check various means of disabling these flags, including disabling them after
122// they've been enabled via an umbrella flag.
123// RUN: %clang -### -fno-honor-infinities -fhonor-infinities -c %s 2>&1 \
124// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
125// RUN: %clang -### -ffinite-math-only -fhonor-infinities -c %s 2>&1 \
126// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
127// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
128// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
129// RUN: %clang -### -ffast-math -fhonor-infinities -c %s 2>&1 \
130// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
131// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
132// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
133// CHECK-NO-NO-INFS: "-cc1"
134// CHECK-NO-NO-INFS-NOT: "-menable-no-infs"
135// CHECK-NO-NO-INFS: "-o"
136//
137// RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \
138// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
139// RUN: %clang -### -ffinite-math-only -fhonor-nans -c %s 2>&1 \
140// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
141// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
142// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
143// RUN: %clang -### -ffast-math -fhonor-nans -c %s 2>&1 \
144// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
145// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
146// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
147// CHECK-NO-NO-NANS: "-cc1"
148// CHECK-NO-NO-NANS-NOT: "-menable-no-nans"
149// CHECK-NO-NO-NANS: "-o"
150//
151// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
152// RUN: -fno-trapping-math -fno-associative-math -c %s 2>&1 \
153// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
154// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
155// RUN: -fno-trapping-math -fno-reciprocal-math -c %s 2>&1 \
156// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
157// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
158// RUN: -fno-trapping-math -fsigned-zeros -c %s 2>&1 \
159// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
160// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
161// RUN: -fno-trapping-math -ftrapping-math -c %s 2>&1 \
162// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
163// RUN: %clang -### -funsafe-math-optimizations -fno-associative-math -c %s \
164// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
165// RUN: %clang -### -funsafe-math-optimizations -fno-reciprocal-math -c %s \
166// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
167// RUN: %clang -### -funsafe-math-optimizations -fsigned-zeros -c %s 2>&1 \
168// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
169// RUN: %clang -### -funsafe-math-optimizations -ftrapping-math -c %s 2>&1 \
170// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
171// RUN: %clang -### -funsafe-math-optimizations -fno-unsafe-math-optimizations \
172// RUN: -c %s 2>&1 \
173// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
174// RUN: %clang -### -ffast-math -fno-associative-math -c %s 2>&1 \
175// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
176// RUN: %clang -### -ffast-math -fno-reciprocal-math -c %s 2>&1 \
177// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
178// RUN: %clang -### -ffast-math -fsigned-zeros -c %s 2>&1 \
179// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
180// RUN: %clang -### -ffast-math -ftrapping-math -c %s 2>&1 \
181// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
182// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \
183// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
184// CHECK-NO-UNSAFE-MATH: "-cc1"
185// CHECK-NO-UNSAFE-MATH-NOT: "-menable-unsafe-fp-math"
186// CHECK-NO-UNSAFE-MATH: "-o"