mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Only if the other operand of a comparison with Inf is a literal we can be sure that it's not Inf or NaN. Fixes a miscompile rdar://122605966
19 lines
664 B
Swift
19 lines
664 B
Swift
// RUN: %target-swift-frontend -parse-as-library -module-name test %s -O -emit-sil | %FileCheck %s
|
|
|
|
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
|
|
|
|
// CHECK-LABEL: sil @$s4test17dont_fold_inf_cmpySbSfF :
|
|
// CHECK: builtin "fcmp_olt_FPIEEE32"
|
|
// CHECK: } // end sil function '$s4test17dont_fold_inf_cmpySbSfF'
|
|
public func dont_fold_inf_cmp(_ f: Float) -> Bool {
|
|
(f + 0) < .infinity
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$s4test014dont_fold_inf_D4_cmpSbyF :
|
|
// CHECK: builtin "fcmp_olt_FPIEEE32"
|
|
// CHECK: } // end sil function '$s4test014dont_fold_inf_D4_cmpSbyF'
|
|
public func dont_fold_inf_inf_cmp() -> Bool {
|
|
0x1.0p128 < Float.infinity
|
|
}
|
|
|