summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/PowerPC
diff options
context:
space:
mode:
authorGuozhi Wei <carrot@google.com>2019-12-04 16:01:20 -0800
committerGuozhi Wei <carrot@google.com>2019-12-06 09:53:53 -0800
commit72942459d070cbfe6f3524e89c3ac37440be7890 (patch)
tree6a45cb456c8fff75ba7c89eb4156254ef6d485d8 /llvm/test/CodeGen/PowerPC
parent164e0fc5c7f782b174db5c87b37725ea0e174853 (diff)
downloadbcm5719-llvm-72942459d070cbfe6f3524e89c3ac37440be7890.tar.gz
bcm5719-llvm-72942459d070cbfe6f3524e89c3ac37440be7890.zip
[MBP] Avoid tail duplication if it can't bring benefit
Current tail duplication integrated in bb layout is designed to increase the fallthrough from a BB's predecessor to its successor, but we have observed cases that duplication doesn't increase fallthrough, or it brings too much size overhead. To overcome these two issues in function canTailDuplicateUnplacedPreds I add two checks: make sure there is at least one duplication in current work set. the number of duplication should not exceed the number of successors. The modification in hasBetterLayoutPredecessor fixes a bug that potential predecessor must be at the bottom of a chain. Differential Revision: https://reviews.llvm.org/D64376
Diffstat (limited to 'llvm/test/CodeGen/PowerPC')
-rw-r--r--llvm/test/CodeGen/PowerPC/block-placement.mir9
-rw-r--r--llvm/test/CodeGen/PowerPC/branch-opt.ll10
-rw-r--r--llvm/test/CodeGen/PowerPC/expand-contiguous-isel.ll1
-rw-r--r--llvm/test/CodeGen/PowerPC/no-duplicate.ll91
4 files changed, 100 insertions, 11 deletions
diff --git a/llvm/test/CodeGen/PowerPC/block-placement.mir b/llvm/test/CodeGen/PowerPC/block-placement.mir
index 9dc911f785b..34c4f1c7b69 100644
--- a/llvm/test/CodeGen/PowerPC/block-placement.mir
+++ b/llvm/test/CodeGen/PowerPC/block-placement.mir
@@ -210,13 +210,12 @@ body: |
; CHECK: bb.5.if.else.i:
; CHECK: successors: %bb.11(0x80000000)
- ; CHECK: B %bb.11
-
- ; CHECK: bb.8.while.body.i (align 16):
- ; CHECK: successors: %bb.11(0x04000000), %bb.9(0x7c000000)
- ; CHECK: BCC 76, killed renamable $cr0, %bb.11
; CHECK: bb.11:
; CHECK: renamable $x3 = LI8 1
; CHECK-NEXT: BLR8 implicit $lr8, implicit $rm, implicit killed $x3
+
+ ; CHECK: bb.8.while.body.i (align 16):
+ ; CHECK: successors: %bb.11(0x04000000), %bb.9(0x7c000000)
+ ; CHECK: BCC 76, killed renamable $cr0, %bb.11
...
diff --git a/llvm/test/CodeGen/PowerPC/branch-opt.ll b/llvm/test/CodeGen/PowerPC/branch-opt.ll
index 5e31270840b..af75e761dbf 100644
--- a/llvm/test/CodeGen/PowerPC/branch-opt.ll
+++ b/llvm/test/CodeGen/PowerPC/branch-opt.ll
@@ -8,13 +8,11 @@ target triple = "powerpc-unknown-linux-gnu"
; The last (whichever it is) should have a fallthrough exit, and the other three
; need an unconditional branch. No other block should have an unconditional
; branch to cond_next48
-; One of the blocks ends up with a loop exit block that gets a tail-duplicated copy
-; of %cond_next48, so there should only be two unconditional branches.
-;CHECK: b .LBB0_13
-;CHECK: b .LBB0_13
-;CHECK-NOT: b .LBB0_13
-;CHECK: .LBB0_13: # %cond_next48
+;CHECK: .LBB0_7: # %cond_next48
+;CHECK: b .LBB0_7
+;CHECK: b .LBB0_7
+;CHECK: b .LBB0_7
define void @foo(i32 %W, i32 %X, i32 %Y, i32 %Z) {
entry:
diff --git a/llvm/test/CodeGen/PowerPC/expand-contiguous-isel.ll b/llvm/test/CodeGen/PowerPC/expand-contiguous-isel.ll
index 86caedcc09f..1acb3e17a7f 100644
--- a/llvm/test/CodeGen/PowerPC/expand-contiguous-isel.ll
+++ b/llvm/test/CodeGen/PowerPC/expand-contiguous-isel.ll
@@ -137,6 +137,7 @@ _ZNK4llvm9StringRef6substrEmm.exit:
; CHECK: bc 12, eq, [[TRUE:.LBB[0-9]+]]
; CHECK-NEXT: b [[SUCCESSOR:.LBB[0-9]+]]
; CHECK-NEXT: [[TRUE]]
+; CHECK-NEXT: # in Loop: Header
; CHECK-NEXT: addi {{r[0-9]+}}, {{r[0-9]+}}, 0
; CHECK-NEXT: [[SUCCESSOR]]
}
diff --git a/llvm/test/CodeGen/PowerPC/no-duplicate.ll b/llvm/test/CodeGen/PowerPC/no-duplicate.ll
new file mode 100644
index 00000000000..932ef1aa106
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/no-duplicate.ll
@@ -0,0 +1,91 @@
+; RUN: llc -O2 < %s | FileCheck %s
+
+target triple = "powerpc64le-grtev4-linux-gnu"
+
+; No duplication of loop header into entry block.
+define void @no_duplicate1(i64 %a) {
+; CHECK-LABEL: no_duplicate1
+; CHECK: mr 30, 3
+; CHECK-NEXT: b .LBB0_2
+
+; CHECK: .LBB0_2:
+; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT: cmpldi 30, 100
+; CHECK-NEXT: bne 0, .LBB0_1
+entry:
+ br label %header
+
+header:
+ %ind = phi i64 [%a, %entry], [%val3, %latch]
+ %cond1 = icmp eq i64 %ind, 100
+ br i1 %cond1, label %middle, label %latch
+
+middle:
+ %condx = call i1 @foo()
+ %val1 = xor i64 %ind, 2
+ br label %latch
+
+latch:
+ %val2 = phi i64 [%ind, %header], [%val1, %middle]
+ %val3 = add i64 %val2, 1
+ %cond2 = call i1 @foo()
+ br i1 %cond2, label %end, label %header
+
+end:
+ ret void
+}
+
+; No duplication of loop header into latches.
+define void @no_duplicate2(i64 %a) {
+; CHECK-LABEL: no_duplicate2
+; CHECK: mr 30, 3
+; CHECK-NEXT: b .LBB1_2
+
+; CHECK: .LBB1_2:
+; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT: cmpldi 30, 100
+; CHECK-NEXT: bne 0, .LBB1_1
+
+; CHECK: %latch2
+; CHECK: b .LBB1_2
+
+; CHECK: %latch3
+; CHECK: b .LBB1_2
+entry:
+ br label %header
+
+header:
+ %ind = phi i64 [%a, %entry], [%val1, %latch1], [%val2, %latch2], [%val2, %latch3]
+ %cond1 = icmp eq i64 %ind, 100
+ br i1 %cond1, label %middle1, label %latch1
+
+latch1:
+ %cond2 = call i1 @foo()
+ %val1 = xor i64 %ind, 2
+ br i1 %cond2, label %end, label %header
+
+middle1:
+ %cond3 = call i1 @foo()
+ br i1 %cond3, label %latch1, label %middle2
+
+middle2:
+ %cond4 = call i1 @foo()
+ %val2 = add i64 %ind, 1
+ br i1 %cond4, label %latch2, label %latch3
+
+latch2:
+ call void @a()
+ br label %header
+
+latch3:
+ call void @b()
+ br label %header
+
+end:
+ ret void
+}
+
+
+declare i1 @foo()
+declare void @a()
+declare void @b()
OpenPOWER on IntegriCloud