Skip to content

Commit e5cf34d

Browse files
committed
---
yaml --- r: 345596 b: refs/heads/master c: dae3951 h: refs/heads/master
1 parent df4f266 commit e5cf34d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a1532869be8652ca1e88857cf4fc868a42b5d4d2
2+
refs/heads/master: dae3951325221f1354964e24a173e5087a5f573a
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ SILInstruction *SILCombiner::optimizeBuiltinZextOrBitCast(BuiltinInst *I) {
161161
replaceInstUsesWith(*I, NI);
162162
return eraseInstFromFunction(*I);
163163
}
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+
}
164176
return nullptr;
165177
}
166178

trunk/test/SILOptimizer/sil_combine.sil

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3637,3 +3637,15 @@ bb0:
36373637
return %36 : $Builtin.Int64
36383638
}
36393639

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+

0 commit comments

Comments
 (0)