Skip to content

Commit 10d3c6b

Browse files
authored
[ShrinkWrap] Consider constant pool access as non-stack access (#164393)
As far as I understand, constant pool access does not access stack and accesses read-only memory. This patch considers constant pool access as non-stack access allowing shrink wrapping to happen in the concerned test. We should be seeing perf improvement with povray benchmark from SPEC17(around 12% with -flto -Ofast) after this patch. An NFC PR #162476 already exists to upload the test before the patch but approval has got delayed. So, as @davemgreen suggested in that PR, I have uploaded the test and patch in this single PR to show how test looks like.
1 parent cde4457 commit 10d3c6b

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

llvm/lib/CodeGen/ShrinkWrap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ bool ShrinkWrapImpl::useOrDefCSROrFI(const MachineInstr &MI, RegScavenger *RS,
319319
return isa<GlobalValue>(UO);
320320
}
321321
if (const PseudoSourceValue *PSV = Op->getPseudoValue())
322-
return PSV->isJumpTable();
322+
return PSV->isJumpTable() || PSV->isConstantPool();
323323
return false;
324324
};
325325
// Load/store operations may access the stack indirectly when we previously

llvm/test/CodeGen/AArch64/shrink-wrap-const-pool-access.mir

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
br label %common.ret
2222
}
2323
...
24-
# FIXME: Following code has a load from constant pool. Accessing constant pool
24+
# Following code has a load from constant pool. Accessing constant pool
2525
# must not be considered as a stack access and hence, shrink wrapping must
2626
# happen.
27-
# CHECK-LABEL:name: shrink_wrap_load_from_const_pool
28-
# CHECK-NOT: savePoint
29-
# CHECK-NOT: restorePoint
27+
# CHECK-LABEL:name: shrink_wrap_load_from_const_pool
28+
# CHECK: savePoint:
29+
# CHECK: - point: '%bb.3'
30+
# CHECK: restorePoint:
31+
# CHECK: - point: '%bb.5'
3032
---
3133
name: shrink_wrap_load_from_const_pool
3234
tracksRegLiveness: true

llvm/test/CodeGen/X86/fp128-select.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ define void @test_select(ptr %p, ptr %q, i1 zeroext %c) nounwind {
1313
; SSE: # %bb.0:
1414
; SSE-NEXT: testl %edx, %edx
1515
; SSE-NEXT: jne .LBB0_1
16-
; SSE-NEXT: # %bb.3:
17-
; SSE-NEXT: movaps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
16+
; SSE-NEXT: # %bb.2:
17+
; SSE-NEXT: movaps {{.*#+}} xmm0 = [NaN]
1818
; SSE-NEXT: movaps %xmm0, (%rsi)
1919
; SSE-NEXT: retq
2020
; SSE-NEXT: .LBB0_1:
@@ -58,7 +58,7 @@ define fp128 @test_select_cc(fp128, fp128) nounwind {
5858
; SSE-NEXT: xorps %xmm1, %xmm1
5959
; SSE-NEXT: jmp .LBB1_3
6060
; SSE-NEXT: .LBB1_1:
61-
; SSE-NEXT: movaps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
61+
; SSE-NEXT: movaps {{.*#+}} xmm1 = [1.0E+0]
6262
; SSE-NEXT: .LBB1_3: # %BB0
6363
; SSE-NEXT: testl %ebx, %ebx
6464
; SSE-NEXT: movaps (%rsp), %xmm0 # 16-byte Reload

0 commit comments

Comments
 (0)