mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Basically the pattern to optimize is:
inject_enum_addr %stackloc, #SomeCase
switch_enum_addr %stackloc ...
This works even if the enum is resilient and the case does not have a payload. As long as we don't have opaque values in SIL we need this peephole to optimize the pattern.
This change fixes the code generation for Float.rounded().
rdar://problem/46353885
40 lines
722 B
Swift
40 lines
722 B
Swift
// RUN: %target-resilience-test --backward-deployment
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
import backward_deploy_enum
|
|
|
|
// <rdar://problem/46438568>
|
|
// REQUIRES: rdar46438568
|
|
|
|
var BackwardDeployEnumTest = TestSuite("BackwardDeployEnum")
|
|
|
|
func checkIt(_ e: ResilientEnum) -> Int {
|
|
switch e {
|
|
case .first:
|
|
return 1
|
|
case .second:
|
|
return 2
|
|
case .third:
|
|
return 3
|
|
case .fourth:
|
|
return 4
|
|
default:
|
|
return 5
|
|
}
|
|
}
|
|
|
|
BackwardDeployEnumTest.test("ResilientEnum") {
|
|
|
|
expectEqual(1, checkIt(.first))
|
|
expectEqual(2, checkIt(.second))
|
|
expectEqual(4, checkIt(.fourth))
|
|
expectEqual(5, checkIt(.fifth))
|
|
|
|
if getVersion() == 1 {
|
|
expectEqual(3, checkIt(.third))
|
|
}
|
|
}
|
|
|
|
runAllTests()
|