mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
* `sitofp` signed integer to floating point * `rint` round floating point to integral * `bitcast` between integer and floating point Constant folding `bitcast`s also made it necessary to rewrite constant folding for Nan and inf values, because the old code explicitly checked for `bitcast` intrinsics. Relying on constant folded `bitcast`s makes the new version much simpler. It is important to constant fold these intrinsics already in SIL because it enables other optimizations.
10 lines
474 B
Swift
10 lines
474 B
Swift
// Constant globals on integer expressions
|
|
// REQUIRES: swift_feature_CompileTimeValues
|
|
// RUN: %target-swift-frontend -emit-ir -primary-file %s -parse-as-library -enable-experimental-feature CompileTimeValues -verify
|
|
|
|
@const let constGlobal1: Int = (42 + 42 + 42) / 3
|
|
@const let constGlobal2: Int = MemoryLayout<UInt32>.size + 4
|
|
@const let constGlobal3: Int = Int(17.0 / 3.5)
|
|
@const let constGlobal4: Int = constGlobal1 + 1
|
|
@const let constGlobal5: Int = -constGlobal1 + 1
|