1; RUN: llc < %s -mcpu cortex-a53 -mtriple=aarch64-eabi | FileCheck %s --check-prefix=A53
2
3; PR26827 - Merge stores causes wrong dependency.
4%struct1 = type { %struct1*, %struct1*, i32, i32, i16, i16, void (i32, i32, i8*)*, i8* }
5@gv0 = internal unnamed_addr global i32 0, align 4
6@gv1 = internal unnamed_addr global %struct1** null, align 8
7
8define void @test(%struct1* %fde, i32 %fd, void (i32, i32, i8*)* %func, i8* %arg)  {
9;CHECK-LABEL: test
10entry:
11; A53: mov [[DATA:w[0-9]+]], w1
12; A53: str q{{[0-9]+}}, {{.*}}
13; A53: str q{{[0-9]+}}, {{.*}}
14; A53: str w1, {{.*}}
15
16  %0 = bitcast %struct1* %fde to i8*
17  tail call void @llvm.memset.p0i8.i64(i8* align 8 %0, i8 0, i64 40, i1 false)
18  %state = getelementptr inbounds %struct1, %struct1* %fde, i64 0, i32 4
19  store i16 256, i16* %state, align 8
20  %fd1 = getelementptr inbounds %struct1, %struct1* %fde, i64 0, i32 2
21  store i32 %fd, i32* %fd1, align 8
22  %force_eof = getelementptr inbounds %struct1, %struct1* %fde, i64 0, i32 3
23  store i32 0, i32* %force_eof, align 4
24  %func2 = getelementptr inbounds %struct1, %struct1* %fde, i64 0, i32 6
25  store void (i32, i32, i8*)* %func, void (i32, i32, i8*)** %func2, align 8
26  %arg3 = getelementptr inbounds %struct1, %struct1* %fde, i64 0, i32 7
27  store i8* %arg, i8** %arg3, align 8
28  %call = tail call i32 (i32, i32, ...) @fcntl(i32 %fd, i32 4, i8* %0) #6
29  %1 = load i32, i32* %fd1, align 8
30  %cmp.i = icmp slt i32 %1, 0
31  br i1 %cmp.i, label %if.then.i, label %while.body.i.preheader
32if.then.i:
33  unreachable
34
35while.body.i.preheader:
36  %2 = load i32, i32* @gv0, align 4
37  %3 = icmp eq i32* %fd1, @gv0
38  br i1 %3, label %while.body.i.split, label %while.body.i.split.ver.us.preheader
39
40while.body.i.split.ver.us.preheader:
41  br label %while.body.i.split.ver.us
42
43while.body.i.split.ver.us:
44  %.reg2mem21.0 = phi i32 [ %mul.i.ver.us, %while.body.i.split.ver.us ], [ %2, %while.body.i.split.ver.us.preheader ]
45  %mul.i.ver.us = shl nsw i32 %.reg2mem21.0, 1
46  %4 = icmp sgt i32 %mul.i.ver.us, %1
47  br i1 %4, label %while.end.i, label %while.body.i.split.ver.us
48
49while.body.i.split:
50  br label %while.body.i.split
51
52while.end.i:
53  %call.i = tail call i8* @foo()
54  store i8* %call.i, i8** bitcast (%struct1*** @gv1 to i8**), align 8
55  br label %exit
56
57exit:
58  ret void
59}
60
61declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1)
62declare i32 @fcntl(i32, i32, ...)
63declare noalias i8* @foo()
64