summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2014-04-02 09:03:43 +0000
committerRenato Golin <renato.golin@linaro.org>2014-04-02 09:03:43 +0000
commitd93295ea56f175127fcc975bdfb72144165a3e0f (patch)
tree2c7c612ab135b529c81b7b701a9c0ea7c909bc44 /llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll
parent7b8d263998cd4534561150c6f529c3cbc389f3b8 (diff)
downloadbcm5719-llvm-d93295ea56f175127fcc975bdfb72144165a3e0f.tar.gz
bcm5719-llvm-d93295ea56f175127fcc975bdfb72144165a3e0f.zip
Remove duplicated DMB instructions
ARM specific optimiztion, finding places in ARM machine code where 2 dmbs follow one another, and eliminating one of them. Patch by Reinoud Elhorst. llvm-svn: 205409
Diffstat (limited to 'llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll')
-rw-r--r--llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll74
1 files changed, 74 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll b/llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll
new file mode 100644
index 00000000000..64f5e202d36
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/optimize-dmbs-v7.ll
@@ -0,0 +1,74 @@
+; RUN: llc < %s -mtriple=armv7 -mattr=+db | FileCheck %s
+
+@x1 = global i32 0, align 4
+@x2 = global i32 0, align 4
+
+define void @test() {
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %i.013 = phi i32 [ 1, %entry ], [ %inc6, %for.body ]
+ store atomic i32 %i.013, i32* @x1 seq_cst, align 4
+ store atomic i32 %i.013, i32* @x1 seq_cst, align 4
+ store atomic i32 %i.013, i32* @x2 seq_cst, align 4
+ %inc6 = add nsw i32 %i.013, 1
+ %exitcond = icmp eq i32 %inc6, 2
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ ret void
+
+; The for.body contains 3 seq_cst stores.
+; Hence it should have 3 dmb;str;dmb sequences with the middle dmbs collapsed
+; CHECK: %for.body
+; CHECK-NOT: str
+; CHECK: dmb
+; CHECK-NOT: dmb
+; CHECK: str
+
+; CHECK-NOT: str
+; CHECK: dmb
+; CHECK-NOT: dmb
+; CHECK: str
+
+; CHECK-NOT: str
+; CHECK: dmb
+; CHECK-NOT: dmb
+; CHECK: str
+
+; CHECK-NOT: str
+; CHECK: dmb
+; CHECK-NOT: dmb
+; CHECK-NOT: str
+; CHECK: %for.end
+}
+
+define void @test2() {
+ call void @llvm.arm.dmb(i32 11)
+ tail call void @test()
+ call void @llvm.arm.dmb(i32 11)
+ ret void
+; the call should prevent the two dmbs from collapsing
+; CHECK: test2:
+; CHECK: dmb
+; CHECK-NEXT: bl
+; CHECK-NEXT: dmb
+}
+
+define void @test3() {
+ call void @llvm.arm.dmb(i32 11)
+ call void @llvm.arm.dsb(i32 9)
+ call void @llvm.arm.dmb(i32 11)
+ ret void
+; the call should prevent the two dmbs from collapsing
+; CHECK: test3:
+; CHECK: dmb
+; CHECK-NEXT: dsb
+; CHECK-NEXT: dmb
+
+}
+
+
+declare void @llvm.arm.dmb(i32)
+declare void @llvm.arm.dsb(i32)
OpenPOWER on IntegriCloud