summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/code_placement_no_header_change.ll
diff options
context:
space:
mode:
authorGuozhi Wei <carrot@google.com>2019-01-25 19:45:13 +0000
committerGuozhi Wei <carrot@google.com>2019-01-25 19:45:13 +0000
commit81f3fd4bf81247480d2fa172a65b04951e7a0d3e (patch)
tree0bb6b2d6785872d844ecf88b1a11a1001f54d6cb /llvm/test/CodeGen/X86/code_placement_no_header_change.ll
parent165ea58798b2f51180a44ae734d8da8a06abf81a (diff)
downloadbcm5719-llvm-81f3fd4bf81247480d2fa172a65b04951e7a0d3e.tar.gz
bcm5719-llvm-81f3fd4bf81247480d2fa172a65b04951e7a0d3e.zip
[MBP] Don't move bottom block before header if it can't reduce taken branches
If bottom of block BB has only one successor OldTop, in most cases it is profitable to move it before OldTop, except the following case: -->OldTop<- | . | | . | | . | ---Pred | | | BB----- Move BB before OldTop can't reduce the number of taken branches, this patch detects this case and prevent the moving. Differential Revision: https://reviews.llvm.org/D57067 llvm-svn: 352236
Diffstat (limited to 'llvm/test/CodeGen/X86/code_placement_no_header_change.ll')
-rw-r--r--llvm/test/CodeGen/X86/code_placement_no_header_change.ll36
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/code_placement_no_header_change.ll b/llvm/test/CodeGen/X86/code_placement_no_header_change.ll
new file mode 100644
index 00000000000..0275606568c
--- /dev/null
+++ b/llvm/test/CodeGen/X86/code_placement_no_header_change.ll
@@ -0,0 +1,36 @@
+; RUN: llc -mtriple=i686-linux < %s | FileCheck %s
+
+
+define i32 @bar(i32 %count) {
+; Test checks that basic block backedge2 is not moved before header,
+; because it can't reduce taken branches.
+; Later backedge1 and backedge2 is rotated before loop header.
+; CHECK-LABEL: bar
+; CHECK: %.entry
+; CHECK: %.backedge1
+; CHECK: %.backedge2
+; CHECK: %.header
+; CHECK: %.exit
+.entry:
+ %c = shl nsw i32 %count, 2
+ br label %.header
+
+.header:
+ %val1 = call i32 @foo()
+ %cond1 = icmp sgt i32 %val1, 1
+ br i1 %cond1, label %.exit, label %.backedge1
+
+.backedge1:
+ %val2 = call i32 @foo()
+ %cond2 = icmp sgt i32 %val2, 1
+ br i1 %cond2, label %.header, label %.backedge2
+
+.backedge2:
+ %val3 = call i32 @foo()
+ br label %.header
+
+.exit:
+ ret i32 %c
+}
+
+declare i32 @foo()
OpenPOWER on IntegriCloud