xref: /llvm-project/llvm/test/CodeGen/Hexagon/fixed-spill-mutable.ll (revision 2208c97c1bec2512d4e47b6223db6d95a7037956)
1; RUN: llc -mtriple=hexagon < %s | FileCheck %s
2
3; The early return is predicated, and the save-restore code is mixed together:
4; {
5;   p0 = cmp.eq(r0, #0)
6;   if (p0.new) r17:16 = memd(r29 + #0)
7;   memd(r29+#0) = r17:16
8; }
9; {
10;   if (p0) dealloc_return
11; }
12; The problem is that the load will execute before the store, clobbering the
13; pair r17:16.
14;
15; Check that the store and the load are not in the same packet.
16; CHECK: memd{{.*}} = r17:16
17; CHECK: }
18; CHECK: r17:16 = memd
19; CHECK-LABEL: LBB0_1:
20
21target triple = "hexagon"
22
23%struct.0 = type { ptr, ptr, ptr, ptr, ptr }
24%struct.1 = type { [60 x i8], i32, ptr }
25%struct.2 = type { i8, i8, i8, i8, %union.anon }
26%union.anon = type { ptr }
27%struct.3 = type { ptr, ptr }
28
29@var = external hidden unnamed_addr global ptr, align 4
30
31declare void @bar(ptr, i32) local_unnamed_addr #0
32
33define void @foo() local_unnamed_addr #1 {
34entry:
35  %.pr = load ptr, ptr @var, align 4, !tbaa !1
36  %cmp2 = icmp eq ptr %.pr, null
37  br i1 %cmp2, label %while.end, label %while.body.preheader
38
39while.body.preheader:                             ; preds = %entry
40  br label %while.body
41
42while.body:                                       ; preds = %while.body.preheader, %while.body
43  %0 = phi ptr [ %4, %while.body ], [ %.pr, %while.body.preheader ]
44  %right = getelementptr inbounds %struct.0, ptr %0, i32 0, i32 4
45  %1 = bitcast ptr %right to ptr
46  %2 = load i32, ptr %1, align 4, !tbaa !5
47  %3 = bitcast ptr %0 to ptr
48  tail call void @bar(ptr %3, i32 20) #1
49  store i32 %2, ptr @var, align 4, !tbaa !1
50  %4 = inttoptr i32 %2 to ptr
51  %cmp = icmp eq i32 %2, 0
52  br i1 %cmp, label %while.end.loopexit, label %while.body
53
54while.end.loopexit:                               ; preds = %while.body
55  br label %while.end
56
57while.end:                                        ; preds = %while.end.loopexit, %entry
58  ret void
59}
60
61attributes #0 = { optsize }
62attributes #1 = { nounwind optsize }
63
64!1 = !{!2, !2, i64 0}
65!2 = !{!"any pointer", !3, i64 0}
66!3 = !{!"omnipotent char", !4, i64 0}
67!4 = !{!"Simple C/C++ TBAA"}
68!5 = !{!6, !2, i64 16}
69!6 = !{!"0", !2, i64 0, !2, i64 4, !2, i64 8, !2, i64 12, !2, i64 16}
70