File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed
SwiftCompilerSources/Sources/Optimizer/InstructionSimplification Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,9 @@ extension BuiltinInst : OnoneSimplifyable {
4040 . AssignCopyArrayNoAlias,
4141 . AssignCopyArrayFrontToBack,
4242 . AssignCopyArrayBackToFront,
43- . AssignTakeArray:
44- optimizeArrayBuiltin ( context)
43+ . AssignTakeArray,
44+ . IsPOD:
45+ optimizeFirstArgumentToThinMetatype ( context)
4546 default :
4647 if let literal = constantFold ( context) {
4748 uses. replaceAll ( with: literal, context)
@@ -173,7 +174,7 @@ private extension BuiltinInst {
173174 context. erase ( instruction: self )
174175 }
175176
176- func optimizeArrayBuiltin ( _ context: SimplifyContext ) {
177+ func optimizeFirstArgumentToThinMetatype ( _ context: SimplifyContext ) {
177178 guard let metatypeInst = operands [ 0 ] . value as? MetatypeInst ,
178179 metatypeInst. type. representationOfMetatype ( in: parentFunction) == . Thick else {
179180 return
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-emit-ir %s -parse-stdlib -module-name Swift -enable-experimental-feature Embedded -wmo -target arm64e-apple-none | %FileCheck %s
2+
3+ // REQUIRES: swift_in_compiler
4+
5+ class MyClass { }
6+
7+ struct MyStruct {
8+ var c : MyClass
9+ }
10+
11+ public func foo( ) -> Builtin . Int1 {
12+ return Builtin . ispod ( MyStruct . self)
13+ }
14+
15+ // CHECK: define {{.*}}i1 @"$ss3fooBi1_yF"()
16+ // CHECK-NEXT: entry:
17+ // CHECK-NEXT: ret i1 false
18+ // CHECK-NEXT: }
19+
20+ public func bar( ) -> Builtin . Int1 {
21+ var s = MyGenericStruct < MyStruct > ( )
22+ return s. foo ( )
23+ }
24+
25+ public struct MyGenericStruct < T> {
26+ public func foo( ) -> Builtin . Int1 {
27+ return Builtin . ispod ( T . self)
28+ }
29+ }
30+
31+ // CHECK: define {{.*}}i1 @"$ss15MyGenericStructV3fooBi1_yFs0aC0V_Tg5"()
32+ // CHECK-NEXT: entry:
33+ // CHECK-NEXT: ret i1 false
34+ // CHECK-NEXT: }
You can’t perform that action at this time.
0 commit comments