mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The Swift Simplification pass can do more than the old MandatoryCombine pass: simplification of more instruction types and dead code elimination. The result is a better -Onone performance while still keeping debug info consistent. Currently following code patterns are simplified: * `struct` -> `struct_extract` * `enum` -> `unchecked_enum_data` * `partial_apply` -> `apply` * `br` to a 1:1 related block * `cond_br` with a constant condition * `isConcrete` and `is_same_metadata` builtins More simplifications can be added in the future. rdar://96708429 rdar://104562580
40 lines
1.4 KiB
Swift
40 lines
1.4 KiB
Swift
// RUN: %target-swift-frontend -primary-file %s -module-name=test -Xllvm -sil-print-debuginfo -emit-sil | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
|
|
// CHECK-LABEL: sil [transparent] @$s4test9checkTypeySixs17FixedWidthIntegerRzlF
|
|
@_transparent
|
|
public func checkType<A: FixedWidthInteger>(_ a: A) -> Int {
|
|
// CHECK-NOT: builtin
|
|
// CHECK: debug_step , loc "{{[^"]+}}":[[# @LINE + 1]]
|
|
if _isConcrete(A.self) {
|
|
// CHECK-NOT: builtin
|
|
if A.self == Int.self {
|
|
return 1
|
|
}
|
|
}
|
|
return 0
|
|
}
|
|
// CHECK: } // end sil function '$s4test9checkTypeySixs17FixedWidthIntegerRzlF'
|
|
|
|
// CHECK-LABEL: sil @$s4test0A10IsConcreteSiyF
|
|
public func testIsConcrete() -> Int {
|
|
// CHECK: debug_step , loc "{{[^"]+}}":[[# @LINE + 1]]:3
|
|
checkType(1)
|
|
// CHECK: [[IL:%[0-9]+]] = integer_literal $Builtin.Int{{[0-9]+}}, 1
|
|
// CHECK: [[I:%[0-9]+]] = struct $Int ([[IL]] :
|
|
// CHECK: return [[I]]
|
|
}
|
|
// CHECK: } // end sil function '$s4test0A10IsConcreteSiyF'
|
|
|
|
|
|
// CHECK-LABEL: sil @$s4test0A17MetadatComparisonSbyF
|
|
public func testMetadatComparison() -> Bool {
|
|
// CHECK: debug_step , loc "{{[^"]+}}":[[# @LINE + 1]]
|
|
[String: Int].self == Never.self
|
|
// CHECK: [[IL:%[0-9]+]] = integer_literal $Builtin.Int1, 0
|
|
// CHECK: [[I:%[0-9]+]] = struct $Bool ([[IL]] :
|
|
// CHECK: return [[I]]
|
|
}
|
|
// CHECK: } // end sil function '$s4test0A17MetadatComparisonSbyF'
|