| 1 |
// RUN: %clang_cc1 -fno-strict-float-cast-overflow %s -emit-llvm -o - | FileCheck %s --check-prefix=NOSTRICT |
| 2 |
|
| 3 |
// When compiling with non-standard semantics, use intrinsics to inhibit the optimizer. |
| 4 |
// This used to require a function attribute, so we check that it is NOT here anymore. |
| 5 |
|
| 6 |
// NOSTRICT-LABEL: main |
| 7 |
// NOSTRICT: call i32 @llvm.fptosi.sat.i32.f64 |
| 8 |
// NOSTRICT: call i32 @llvm.fptoui.sat.i32.f64 |
| 9 |
// NOSTRICT-NOT: strict-float-cast-overflow |
| 10 |
|
| 11 |
// The workaround attribute is not applied by default. |
| 12 |
|
| 13 |
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefix=STRICT |
| 14 |
// STRICT-LABEL: main |
| 15 |
// STRICT: = fptosi |
| 16 |
// STRICT: = fptoui |
| 17 |
// STRICT-NOT: strict-float-cast-overflow |
| 18 |
|
| 19 |
|
| 20 |
int main(void) { |
| 21 |
double d = 1e20; |
| 22 |
return (int)d != 1e20 && (unsigned)d != 1e20; |
| 23 |
} |