xref: /aosp_15_r20/external/llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -O1 < %s -mtriple=armv7 -mattr=+db | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker@x1 = global i32 0, align 4
4*9880d681SAndroid Build Coastguard Worker@x2 = global i32 0, align 4
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine void @test() {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker  br label %for.body
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerfor.body:                                         ; preds = %for.body, %entry
11*9880d681SAndroid Build Coastguard Worker  %i.013 = phi i32 [ 1, %entry ], [ %inc6, %for.body ]
12*9880d681SAndroid Build Coastguard Worker  store atomic i32 %i.013, i32* @x1 seq_cst, align 4
13*9880d681SAndroid Build Coastguard Worker  store atomic i32 %i.013, i32* @x1 seq_cst, align 4
14*9880d681SAndroid Build Coastguard Worker  store atomic i32 %i.013, i32* @x2 seq_cst, align 4
15*9880d681SAndroid Build Coastguard Worker  %inc6 = add nsw i32 %i.013, 1
16*9880d681SAndroid Build Coastguard Worker  %exitcond = icmp eq i32 %inc6, 2
17*9880d681SAndroid Build Coastguard Worker  br i1 %exitcond, label %for.end, label %for.body
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerfor.end:                                          ; preds = %for.body
20*9880d681SAndroid Build Coastguard Worker  ret void
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; The for.body contains 3 seq_cst stores.
23*9880d681SAndroid Build Coastguard Worker; Hence it should have 3 dmb;str;dmb sequences with the middle dmbs collapsed
24*9880d681SAndroid Build Coastguard Worker; CHECK: %for.body
25*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: str
26*9880d681SAndroid Build Coastguard Worker; CHECK: dmb
27*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: dmb
28*9880d681SAndroid Build Coastguard Worker; CHECK: str
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: str
31*9880d681SAndroid Build Coastguard Worker; CHECK: dmb
32*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: dmb
33*9880d681SAndroid Build Coastguard Worker; CHECK: str
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: str
36*9880d681SAndroid Build Coastguard Worker; CHECK: dmb
37*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: dmb
38*9880d681SAndroid Build Coastguard Worker; CHECK: str
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: str
41*9880d681SAndroid Build Coastguard Worker; CHECK: dmb
42*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: dmb
43*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: str
44*9880d681SAndroid Build Coastguard Worker; CHECK: %for.end
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerdefine void @test2() {
48*9880d681SAndroid Build Coastguard Worker  call void @llvm.arm.dmb(i32 11)
49*9880d681SAndroid Build Coastguard Worker  tail call void @test()
50*9880d681SAndroid Build Coastguard Worker  call void @llvm.arm.dmb(i32 11)
51*9880d681SAndroid Build Coastguard Worker  ret void
52*9880d681SAndroid Build Coastguard Worker; the call should prevent the two dmbs from collapsing
53*9880d681SAndroid Build Coastguard Worker; CHECK: test2:
54*9880d681SAndroid Build Coastguard Worker; CHECK: dmb
55*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: bl
56*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: dmb
57*9880d681SAndroid Build Coastguard Worker}
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Workerdefine void @test3() {
60*9880d681SAndroid Build Coastguard Worker  call void @llvm.arm.dmb(i32 11)
61*9880d681SAndroid Build Coastguard Worker  call void @llvm.arm.dsb(i32 9)
62*9880d681SAndroid Build Coastguard Worker  call void @llvm.arm.dmb(i32 11)
63*9880d681SAndroid Build Coastguard Worker  ret void
64*9880d681SAndroid Build Coastguard Worker; the call should prevent the two dmbs from collapsing
65*9880d681SAndroid Build Coastguard Worker; CHECK: test3:
66*9880d681SAndroid Build Coastguard Worker; CHECK: dmb
67*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: dsb
68*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: dmb
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Worker}
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.arm.dmb(i32)
74*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.arm.dsb(i32)
75