1 // 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 // 7 // RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \ 8 // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s 9 // CHECK-NO-INFS: "-cc1" 10 // CHECK-NO-INFS: "-menable-no-infs" 11 // 12 // RUN: %clang -### -fno-honor-nans -c %s 2>&1 \ 13 // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s 14 // CHECK-NO-NANS: "-cc1" 15 // CHECK-NO-NANS: "-menable-no-nans" 16 // 17 // RUN: %clang -### -fmath-errno -c %s 2>&1 \ 18 // RUN: | FileCheck --check-prefix=CHECK-MATH-ERRNO %s 19 // CHECK-MATH-ERRNO: "-cc1" 20 // CHECK-MATH-ERRNO: "-fmath-errno" 21 // 22 // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ 23 // RUN: -fno-trapping-math -c %s 2>&1 \ 24 // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s 25 // CHECK-UNSAFE-MATH: "-cc1" 26 // CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math" 27 // 28 // Check that various umbrella flags also enable these frontend options. 29 // RUN: %clang -### -ffast-math -c %s 2>&1 \ 30 // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s 31 // RUN: %clang -### -ffast-math -c %s 2>&1 \ 32 // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s 33 // RUN: %clang -### -ffast-math -c %s 2>&1 \ 34 // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s 35 // RUN: %clang -### -ffinite-math-only -c %s 2>&1 \ 36 // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s 37 // RUN: %clang -### -ffinite-math-only -c %s 2>&1 \ 38 // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s 39 // RUN: %clang -### -funsafe-math-optimizations -c %s 2>&1 \ 40 // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s 41 // 42 // One umbrella flag is *really* weird and also changes the semantics of the 43 // program by adding a special preprocessor macro. Check that the frontend flag 44 // modeling this semantic change is provided. Also check that the semantic 45 // impact remains even if every optimization is disabled. 46 // RUN: %clang -### -ffast-math -c %s 2>&1 \ 47 // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s 48 // RUN: %clang -### -ffast-math -fno-finite-math-only \ 49 // RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \ 50 // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s 51 // CHECK-FAST-MATH: "-cc1" 52 // CHECK-FAST-MATH: "-ffast-math" 53 // 54 // Check various means of disabling these flags, including disabling them after 55 // they've been enabled via an umbrella flag. 56 // RUN: %clang -### -fno-honor-infinities -fhonor-infinities -c %s 2>&1 \ 57 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s 58 // RUN: %clang -### -ffinite-math-only -fhonor-infinities -c %s 2>&1 \ 59 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s 60 // RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \ 61 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s 62 // RUN: %clang -### -ffast-math -fhonor-infinities -c %s 2>&1 \ 63 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s 64 // RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \ 65 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s 66 // CHECK-NO-NO-INFS: "-cc1" 67 // CHECK-NO-NO-INFS-NOT: "-menable-no-infs" 68 // CHECK-NO-NO-INFS: "-o" 69 // 70 // RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \ 71 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s 72 // RUN: %clang -### -ffinite-math-only -fhonor-nans -c %s 2>&1 \ 73 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s 74 // RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \ 75 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s 76 // RUN: %clang -### -ffast-math -fhonor-nans -c %s 2>&1 \ 77 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s 78 // RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \ 79 // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s 80 // CHECK-NO-NO-NANS: "-cc1" 81 // CHECK-NO-NO-NANS-NOT: "-menable-no-nans" 82 // CHECK-NO-NO-NANS: "-o" 83 // 84 // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ 85 // RUN: -fno-trapping-math -fno-associative-math -c %s 2>&1 \ 86 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 87 // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ 88 // RUN: -fno-trapping-math -fno-reciprocal-math -c %s 2>&1 \ 89 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 90 // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ 91 // RUN: -fno-trapping-math -fsigned-zeros -c %s 2>&1 \ 92 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 93 // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ 94 // RUN: -fno-trapping-math -ftrapping-math -c %s 2>&1 \ 95 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 96 // RUN: %clang -### -funsafe-math-optimizations -fno-associative-math -c %s \ 97 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 98 // RUN: %clang -### -funsafe-math-optimizations -fno-reciprocal-math -c %s \ 99 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 100 // RUN: %clang -### -funsafe-math-optimizations -fsigned-zeros -c %s 2>&1 \ 101 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 102 // RUN: %clang -### -funsafe-math-optimizations -ftrapping-math -c %s 2>&1 \ 103 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 104 // RUN: %clang -### -funsafe-math-optimizations -fno-unsafe-math-optimizations \ 105 // RUN: -c %s 2>&1 \ 106 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 107 // RUN: %clang -### -ffast-math -fno-associative-math -c %s 2>&1 \ 108 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 109 // RUN: %clang -### -ffast-math -fno-reciprocal-math -c %s 2>&1 \ 110 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 111 // RUN: %clang -### -ffast-math -fsigned-zeros -c %s 2>&1 \ 112 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 113 // RUN: %clang -### -ffast-math -ftrapping-math -c %s 2>&1 \ 114 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 115 // RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \ 116 // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s 117 // CHECK-NO-UNSAFE-MATH: "-cc1" 118 // CHECK-NO-UNSAFE-MATH-NOT: "-menable-unsafe-fp-math" 119 // CHECK-NO-UNSAFE-MATH: "-o" 120