John McCall | 7fac1ac | 2020-06-11 18:09:36 -0400 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s |
| 2 | |
| 3 | float test_default(float a, float b, float c) { |
| 4 | float tmp = a; |
| 5 | tmp += b; |
| 6 | tmp += c; |
| 7 | return tmp; |
| 8 | } |
| 9 | |
| 10 | // CHECK: define float @_Z12test_defaultfff(float %a, float %b, float %c) [[FAST_ATTRS:#[0-9]+]] |
| 11 | // CHECK: fadd fast float {{%.+}}, {{%.+}} |
| 12 | // CHECK: fadd fast float {{%.+}}, {{%.+}} |
| 13 | |
| 14 | float test_precise_on_pragma(float a, float b, float c) { |
| 15 | float tmp = a; |
| 16 | { |
| 17 | #pragma float_control(precise, on) |
| 18 | tmp += b; |
| 19 | } |
| 20 | tmp += c; |
| 21 | return tmp; |
| 22 | } |
| 23 | |
| 24 | // CHECK: define float @_Z22test_precise_on_pragmafff(float %a, float %b, float %c) [[PRECISE_ATTRS:#[0-9]+]] |
| 25 | // CHECK: fadd float {{%.+}}, {{%.+}} |
| 26 | // CHECK: fadd fast float {{%.+}}, {{%.+}} |
| 27 | |
| 28 | float test_reassociate_off_pragma(float a, float b, float c) { |
| 29 | float tmp = a; |
| 30 | { |
| 31 | #pragma clang fp reassociate(off) |
| 32 | tmp += b; |
| 33 | } |
| 34 | tmp += c; |
| 35 | return tmp; |
| 36 | } |
| 37 | |
| 38 | // CHECK: define float @_Z27test_reassociate_off_pragmafff(float %a, float %b, float %c) [[NOREASSOC_ATTRS:#[0-9]+]] |
| 39 | // CHECK: fadd nnan ninf nsz arcp contract afn float {{%.+}}, {{%.+}} |
| 40 | // CHECK: fadd fast float {{%.+}}, {{%.+}} |
| 41 | |
| 42 | // CHECK: attributes [[FAST_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} } |
| 43 | // CHECK: attributes [[PRECISE_ATTRS]] = { {{.*}}"no-infs-fp-math"="false" {{.*}}"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" {{.*}}"unsafe-fp-math"="false"{{.*}} } |
| 44 | // CHECK: attributes [[NOREASSOC_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="false"{{.*}} } |