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, i8** 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], [2048 x float]* @A, i64 0, i64 %indvars.iv24
20 store float %conv, float* %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], [2048 x float]* @A, i64 0, i64 %4
49 %5 = bitcast float* %arrayidx.i to i32*
50 %6 = load i32, i32* %5, align 4
51 %arrayidx9.i = getelementptr inbounds float, float* getelementptr inbounds ([2048 x float], [2048 x float]* @A, i64 0, i64 1), i64 %4
52 %7 = bitcast float* %arrayidx9.i to i32*
53 %8 = load i32, i32* %7, align 4
54 %9 = shl nsw i64 %indvars.iv.i, 1
55 %10 = add nuw nsw i64 %9, %2
56 %arrayidx14.i = getelementptr inbounds [2048 x float], [2048 x float]* @A, i64 0, i64 %10
57 %11 = bitcast float* %arrayidx14.i to i32*
58 %12 = load i32, i32* %11, align 4
59 %arrayidx19.i = getelementptr inbounds float, float* getelementptr inbounds ([2048 x float], [2048 x float]* @A, i64 0, i64 1), i64 %10
60 %13 = bitcast float* %arrayidx19.i to i32*
61 %14 = load i32, i32* %13, align 4
62 store i32 %6, i32* %11, align 4
63 store i32 %8, i32* %13, align 4
64 store i32 %12, i32* %5, align 4
65 store i32 %14, i32* %7, align 4
66 %indvars.iv.next.i = add nuw nsw i64 %indvars.iv.i, 1
67 %lftr.wideiv = trunc i64 %indvars.iv.next.i to i32
68 %exitcond21 = icmp eq i32 %lftr.wideiv, %indvars.iv19
69 br i1 %exitcond21, label %for.inc.40.i, label %for.body.3.i
71 for.inc.40.i: ; preds = %for.body.3.i
72 %indvars.iv.next58.i = add nuw nsw i64 %indvars.iv57.i, 1
73 %indvars.iv.next20 = add nuw nsw i32 %indvars.iv19, 1
74 %exitcond22 = icmp eq i64 %indvars.iv.next58.i, 32
75 br i1 %exitcond22, label %complex_transpose.exit, label %for.body.3.lr.ph.i
77 complex_transpose.exit: ; preds = %for.inc.40.i
78 %inc9 = add nuw nsw i32 %i.116, 1
79 %exitcond23 = icmp eq i32 %inc9, 10
80 br i1 %exitcond23, label %for.body.14.preheader, label %for.body.3.lr.ph.i.preheader
82 for.body.14.preheader: ; preds = %complex_transpose.exit
85 for.body.14: ; preds = %for.body.14.preheader, %for.body.14
86 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.14 ], [ 0, %for.body.14.preheader ]
87 %sum.115 = phi float [ %add17, %for.body.14 ], [ 0.000000e+00, %for.body.14.preheader ]
88 %arrayidx16 = getelementptr inbounds [2048 x float], [2048 x float]* @A, i64 0, i64 %indvars.iv
89 %15 = load float, float* %arrayidx16, align 4
90 %add17 = fadd float %sum.115, %15
91 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
92 %exitcond = icmp eq i64 %indvars.iv.next, 2048
93 br i1 %exitcond, label %for.end.20, label %for.body.14
95 for.end.20: ; preds = %for.body.14