Files
swift-mirror/test/SILOptimizer/onone_simplifications.swift
Erik Eckstein d25b1ed834 Optimizer: Replace the MandatoryCombine pass with a Simplification pass, which is implemented in Swift
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
2023-02-09 06:50:05 +01:00

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'