File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
lib/SILOptimizer/SILCombiner Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: a1532869be8652ca1e88857cf4fc868a42b5d4d2
2
+ refs/heads/master: dae3951325221f1354964e24a173e5087a5f573a
3
3
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
4
4
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
5
5
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
Original file line number Diff line number Diff line change @@ -161,6 +161,18 @@ SILInstruction *SILCombiner::optimizeBuiltinZextOrBitCast(BuiltinInst *I) {
161
161
replaceInstUsesWith (*I, NI);
162
162
return eraseInstFromFunction (*I);
163
163
}
164
+ // Optimize a sequence of conversion of an builtin integer to and from
165
+ // BridgeObject. This sequence appears in the String implementation.
166
+ if (auto *BO2W = dyn_cast<BridgeObjectToWordInst>(Op)) {
167
+ if (auto *V2BO = dyn_cast<ValueToBridgeObjectInst>(BO2W->getOperand ())) {
168
+ if (auto *SI = dyn_cast<StructInst>(V2BO->getOperand ())) {
169
+ if (SI->getNumOperands () == 1 && SI->getOperand (0 )->getType () == I->getType ()) {
170
+ replaceInstUsesWith (*I, SI->getOperand (0 ));
171
+ return eraseInstFromFunction (*I);
172
+ }
173
+ }
174
+ }
175
+ }
164
176
return nullptr ;
165
177
}
166
178
Original file line number Diff line number Diff line change @@ -3637,3 +3637,15 @@ bb0:
3637
3637
return %36 : $Builtin.Int64
3638
3638
}
3639
3639
3640
+ // CHECK-LABEL: sil @conversion_to_and_from_bridge_object
3641
+ // CHECK: bb0(%0 : $Builtin.Int64):
3642
+ // CHECK-NEXT: return %0
3643
+ sil @conversion_to_and_from_bridge_object : $@convention(thin) (Builtin.Int64) -> (Builtin.Int64) {
3644
+ bb0(%0 : $Builtin.Int64):
3645
+ %1 = struct $UInt64 (%0 : $Builtin.Int64)
3646
+ %2 = value_to_bridge_object %1 : $UInt64
3647
+ %3 = bridge_object_to_word %2 : $Builtin.BridgeObject to $Builtin.Word
3648
+ %4 = builtin "zextOrBitCast_Word_Int64"(%3 : $Builtin.Word) : $Builtin.Int64
3649
+ return %4 : $Builtin.Int64
3650
+ }
3651
+
You can’t perform that action at this time.
0 commit comments