diff options
author | James Molloy <james.molloy@arm.com> | 2016-09-11 08:07:30 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2016-09-11 08:07:30 +0000 |
commit | 18d96e8fa515de0e7cc9a6a0e55c76d2ec4b9d1a (patch) | |
tree | ae14834686fae12edf68529a518b4d78352ff588 /llvm/test/Transforms/SimplifyCFG/sink-common-code.ll | |
parent | 89fda2bde2cf01498fb333baef6613bae02c27a7 (diff) | |
download | bcm5719-llvm-18d96e8fa515de0e7cc9a6a0e55c76d2ec4b9d1a.tar.gz bcm5719-llvm-18d96e8fa515de0e7cc9a6a0e55c76d2ec4b9d1a.zip |
[SimplifyCFG] Harden up the profitability heuristic for block splitting during sinking
Exposed by PR30244, we will split a block currently if we think we can sink at least one instruction. However this isn't right - the reason we split predecessors is so that we can sink instructions that otherwise couldn't be sunk because it isn't safe to do so - stores, for example.
So, change the heuristic to only split if it thinks it can sink at least one non-speculatable instruction.
Should fix PR30244.
llvm-svn: 281160
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG/sink-common-code.ll')
-rw-r--r-- | llvm/test/Transforms/SimplifyCFG/sink-common-code.ll | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll b/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll index b20b53cc65f..c75d2c18aca 100644 --- a/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll +++ b/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll @@ -478,6 +478,35 @@ if.end: ; CHECK-LABEL: test16 ; CHECK: zext +; CHECK: zext + +define zeroext i1 @test16a(i1 zeroext %flag, i1 zeroext %flag2, i32 %blksA, i32 %blksB, i32 %nblks, i8* %p) { + +entry: + br i1 %flag, label %if.then, label %if.else + +if.then: + %cmp = icmp uge i32 %blksA, %nblks + %frombool1 = zext i1 %cmp to i8 + store i8 %frombool1, i8* %p + br label %if.end + +if.else: + br i1 %flag2, label %if.then2, label %if.end + +if.then2: + %add = add i32 %nblks, %blksB + %cmp2 = icmp ule i32 %add, %blksA + %frombool3 = zext i1 %cmp2 to i8 + store i8 %frombool3, i8* %p + br label %if.end + +if.end: + ret i1 true +} + +; CHECK-LABEL: test16a +; CHECK: zext ; CHECK-NOT: zext define zeroext i1 @test17(i32 %flag, i32 %blksA, i32 %blksB, i32 %nblks) { @@ -489,13 +518,13 @@ entry: if.then: %cmp = icmp uge i32 %blksA, %nblks - %frombool1 = zext i1 %cmp to i8 + %frombool1 = call i8 @i1toi8(i1 %cmp) br label %if.end if.then2: %add = add i32 %nblks, %blksB %cmp2 = icmp ule i32 %add, %blksA - %frombool3 = zext i1 %cmp2 to i8 + %frombool3 = call i8 @i1toi8(i1 %cmp2) br label %if.end if.end: @@ -503,6 +532,7 @@ if.end: %tobool4 = icmp ne i8 %obeys.0, 0 ret i1 %tobool4 } +declare i8 @i1toi8(i1) ; CHECK-LABEL: test17 ; CHECK: if.then: @@ -516,7 +546,7 @@ if.end: ; CHECK: [[x]]: ; CHECK-NEXT: %[[y:.*]] = phi i1 [ %cmp -; CHECK-NEXT: %[[z:.*]] = zext i1 %[[y]] +; CHECK-NEXT: %[[z:.*]] = call i8 @i1toi8(i1 %[[y]]) ; CHECK-NEXT: br label %if.end ; CHECK: if.end: @@ -639,6 +669,25 @@ declare void @g() ; CHECK-LABEL: test_pr30292 ; CHECK: phi i32 [ 0, %entry ], [ %add1, %succ ], [ %add2, %two ] +define void @test_pr30244(i1 %cond, i1 %cond2, i32 %a, i32 %b) { +entry: + %add1 = add i32 %a, 1 + br label %succ + +one: + br i1 %cond, label %two, label %succ + +two: + call void @g() + %add2 = add i32 %a, 1 + br label %succ + +succ: + %p = phi i32 [ 0, %entry ], [ %add1, %one ], [ %add2, %two ] + br label %one +} + + ; CHECK: !0 = !{!1, !1, i64 0} ; CHECK: !1 = !{!"float", !2} ; CHECK: !2 = !{!"an example type tree"} |