Skip to content

Commit 5572d04

Browse files
committed
[sil-combine] Enable optimized nested index_addr optimization in ownership.
This just works with transitive addresses meaning that there aren't any ownership issues we need to think about.
1 parent d36fae5 commit 5572d04

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,6 @@ SILInstruction *SILCombiner::visitLoadInst(LoadInst *LI) {
937937
/// ->
938938
/// %2 = index_addr %ptr, x+y
939939
SILInstruction *SILCombiner::visitIndexAddrInst(IndexAddrInst *IA) {
940-
if (IA->getFunction()->hasOwnership())
941-
return nullptr;
942-
943940
unsigned index = 0;
944941
SILValue base = isConstIndexAddr(IA, index);
945942
if (!base)

test/SILOptimizer/sil_combine_ossa.sil

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,12 @@ bb0:
410410
}
411411

412412
// CHECK-LABEL: sil [ossa] @optimize_nested_index_addr
413-
// XHECK: bb0(%0 : $Builtin.RawPointer):
414-
// XHECK-NEXT: %1 = pointer_to_address %0
415-
// XHECK-NEXT: %2 = integer_literal $Builtin.Word, 10
416-
// XHECK-NEXT: %3 = index_addr %1 : $*UInt8, %2
417-
// XHECK-NEXT: %4 = address_to_pointer %3
418-
// XHECK-NEXT: return %4
413+
// CHECK: bb0(%0 : $Builtin.RawPointer):
414+
// CHECK-NEXT: %1 = pointer_to_address %0
415+
// CHECK-NEXT: %2 = integer_literal $Builtin.Word, 10
416+
// CHECK-NEXT: %3 = index_addr %1 : $*UInt8, %2
417+
// CHECK-NEXT: %4 = address_to_pointer %3
418+
// CHECK-NEXT: return %4
419419
sil [ossa] @optimize_nested_index_addr : $@convention(thin) (Builtin.RawPointer) -> Builtin.RawPointer {
420420
bb0(%0 : $Builtin.RawPointer):
421421
%1 = integer_literal $Builtin.Word, 3

0 commit comments

Comments
 (0)