Skip to content

Commit ab975c2

Browse files
committed
[ShrinkWrap][NFC] Test with load from constant pool preventing shrink
wrapping Shrink wrapping treats a load from constant pool as a stack access. This is not correct. Constants are basically stored in read only section AFAIU. This prevents shrink wrapping from kicking in. (Related to PR #160257. PR #160257 will be closed.)
1 parent 3bec46f commit ab975c2

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
--- |
2+
; RUN: llc -x=mir -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s
3+
; CHECK-NOT: savePoint
4+
; CHECK-NOT: restorePoint
5+
6+
declare double @foo()
7+
8+
define double @shrink_wrap_load_from_const_pool(double %q) {
9+
entry:
10+
%0 = fcmp oeq double %q, 3.125500e+02
11+
br i1 %0, label %common.ret, label %if.else
12+
13+
common.ret: ; preds = %if.else, %entry, %exit1
14+
%common.ret.op = phi double [ %3, %exit1 ], [ 0.000000e+00, %entry ], [ 0.000000e+00, %if.else ]
15+
ret double %common.ret.op
16+
17+
if.else: ; preds = %entry
18+
%1 = call double @foo()
19+
%2 = fcmp oeq double %1, 0.000000e+00
20+
br i1 %2, label %exit1, label %common.ret
21+
22+
exit1: ; preds = %if.else
23+
%3 = call double @foo()
24+
br label %common.ret
25+
}
26+
...
27+
---
28+
name: shrink_wrap_load_from_const_pool
29+
tracksRegLiveness: true
30+
constants:
31+
- id: 0
32+
value: 'double 3.125500e+02'
33+
alignment: 8
34+
body: |
35+
bb.0.entry:
36+
successors: %bb.4(0x50000000), %bb.2(0x30000000)
37+
liveins: $d0
38+
39+
renamable $d1 = COPY $d0
40+
renamable $x8 = ADRP target-flags(aarch64-page) %const.0
41+
renamable $d2 = LDRDui killed renamable $x8, target-flags(aarch64-pageoff, aarch64-nc) %const.0 :: (load (s64) from constant-pool)
42+
renamable $d0 = FMOVD0
43+
nofpexcept FCMPDrr killed renamable $d1, killed renamable $d2, implicit-def $nzcv, implicit $fpcr
44+
Bcc 1, %bb.2, implicit killed $nzcv
45+
46+
bb.4:
47+
liveins: $d0
48+
49+
bb.1.common.ret:
50+
liveins: $d0
51+
52+
RET_ReallyLR implicit $d0
53+
54+
bb.2.if.else:
55+
successors: %bb.3(0x50000000), %bb.1(0x30000000)
56+
57+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
58+
BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $d0
59+
ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
60+
renamable $d1 = COPY $d0
61+
renamable $d0 = FMOVD0
62+
nofpexcept FCMPDri killed renamable $d1, implicit-def $nzcv, implicit $fpcr
63+
Bcc 1, %bb.1, implicit killed $nzcv
64+
B %bb.3
65+
66+
bb.3.exit1:
67+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
68+
BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $d0
69+
ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
70+
B %bb.1
71+
...

0 commit comments

Comments
 (0)