1 ; Test that MergeConsecutiveStores() does not during DAG combining
2 ; incorrectly drop a chain dependency to a store previously chained to
3 ; one of two combined loads.
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
7 @A = common global [2048 x float] zeroinitializer, align 4
9 ; Function Attrs: nounwind
10 define signext i32 @main(i32 signext %argc, ptr nocapture readnone %argv) #0 {
14 for.body: ; preds = %for.body, %entry
15 %indvars.iv24 = phi i64 [ 0, %entry ], [ %indvars.iv.next25, %for.body ]
16 %sum.018 = phi float [ 0.000000e+00, %entry ], [ %add, %for.body ]
17 %0 = trunc i64 %indvars.iv24 to i32
18 %conv = sitofp i32 %0 to float
19 %arrayidx = getelementptr inbounds [2048 x float], ptr @A, i64 0, i64 %indvars.iv24
20 store float %conv, ptr %arrayidx, align 4
21 %add = fadd float %sum.018, %conv
22 %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
23 %exitcond26 = icmp eq i64 %indvars.iv.next25, 2048
24 br i1 %exitcond26, label %for.end, label %for.body
26 for.end: ; preds = %for.body
27 br label %for.body.3.lr.ph.i.preheader
29 for.body.3.lr.ph.i.preheader: ; preds = %complex_transpose.exit, %for.end
30 %i.116 = phi i32 [ 0, %for.end ], [ %inc9, %complex_transpose.exit ]
31 br label %for.body.3.lr.ph.i
33 for.body.3.lr.ph.i: ; preds = %for.body.3.lr.ph.i.preheader, %for.inc.40.i
34 %indvars.iv19 = phi i32 [ 1, %for.body.3.lr.ph.i.preheader ], [ %indvars.iv.next20, %for.inc.40.i ]
35 %indvars.iv57.i = phi i64 [ 1, %for.body.3.lr.ph.i.preheader ], [ %indvars.iv.next58.i, %for.inc.40.i ]
36 %1 = shl nsw i64 %indvars.iv57.i, 1
37 %2 = shl nsw i64 %indvars.iv57.i, 6
38 br label %for.body.3.i
40 for.body.3.i: ; preds = %for.body.3.i, %for.body.3.lr.ph.i
41 ; CHECK-LABEL: .LBB0_5:
42 ; CHECK-NOT: stfh %r{{.*}}, 0(%r{{.*}})
43 ; CHECK: lg %r{{.*}}, 8(%r{{.*}})
44 ; Overlapping load should go before the store
45 %indvars.iv.i = phi i64 [ 0, %for.body.3.lr.ph.i ], [ %indvars.iv.next.i, %for.body.3.i ]
46 %3 = shl nsw i64 %indvars.iv.i, 6
47 %4 = add nuw nsw i64 %3, %1
48 %arrayidx.i = getelementptr inbounds [2048 x float], ptr @A, i64 0, i64 %4
49 %5 = load i32, ptr %arrayidx.i, align 4
50 %arrayidx9.i = getelementptr inbounds float, ptr getelementptr inbounds ([2048 x float], ptr @A, i64 0, i64 1), i64 %4
51 %6 = load i32, ptr %arrayidx9.i, align 4
52 %7 = shl nsw i64 %indvars.iv.i, 1
53 %8 = add nuw nsw i64 %7, %2
54 %arrayidx14.i = getelementptr inbounds [2048 x float], ptr @A, i64 0, i64 %8
55 %9 = load i32, ptr %arrayidx14.i, align 4
56 %arrayidx19.i = getelementptr inbounds float, ptr getelementptr inbounds ([2048 x float], ptr @A, i64 0, i64 1), i64 %8
57 %10 = load i32, ptr %arrayidx19.i, align 4
58 store i32 %5, ptr %arrayidx14.i, align 4
59 store i32 %6, ptr %arrayidx19.i, align 4
60 store i32 %9, ptr %arrayidx.i, align 4
61 store i32 %10, ptr %arrayidx9.i, align 4
62 %indvars.iv.next.i = add nuw nsw i64 %indvars.iv.i, 1
63 %lftr.wideiv = trunc i64 %indvars.iv.next.i to i32
64 %exitcond21 = icmp eq i32 %lftr.wideiv, %indvars.iv19
65 br i1 %exitcond21, label %for.inc.40.i, label %for.body.3.i
67 for.inc.40.i: ; preds = %for.body.3.i
68 %indvars.iv.next58.i = add nuw nsw i64 %indvars.iv57.i, 1
69 %indvars.iv.next20 = add nuw nsw i32 %indvars.iv19, 1
70 %exitcond22 = icmp eq i64 %indvars.iv.next58.i, 32
71 br i1 %exitcond22, label %complex_transpose.exit, label %for.body.3.lr.ph.i
73 complex_transpose.exit: ; preds = %for.inc.40.i
74 %inc9 = add nuw nsw i32 %i.116, 1
75 %exitcond23 = icmp eq i32 %inc9, 10
76 br i1 %exitcond23, label %for.body.14.preheader, label %for.body.3.lr.ph.i.preheader
78 for.body.14.preheader: ; preds = %complex_transpose.exit
81 for.body.14: ; preds = %for.body.14.preheader, %for.body.14
82 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.14 ], [ 0, %for.body.14.preheader ]
83 %sum.115 = phi float [ %add17, %for.body.14 ], [ 0.000000e+00, %for.body.14.preheader ]
84 %arrayidx16 = getelementptr inbounds [2048 x float], ptr @A, i64 0, i64 %indvars.iv
85 %11 = load float, ptr %arrayidx16, align 4
86 %add17 = fadd float %sum.115, %11
87 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
88 %exitcond = icmp eq i64 %indvars.iv.next, 2048
89 br i1 %exitcond, label %for.end.20, label %for.body.14
91 for.end.20: ; preds = %for.body.14