mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
Codegen: Fix broken assumption in Tail Merge.
Tail merge was making the assumption that a layout successor or predecessor was always a cfg successor/predecessor. Remove that assumption. Changes to tests are necessary because the errant cfg edges were preventing optimizations. llvm-svn: 273700
This commit is contained in:
parent
94c9b19579
commit
e9b17f6bf5
@ -1255,7 +1255,7 @@ ReoptimizeBlock:
|
|||||||
// where a BB jumps to more than one landing pad.
|
// where a BB jumps to more than one landing pad.
|
||||||
// TODO: Is it ever worth rewriting predecessors which don't already
|
// TODO: Is it ever worth rewriting predecessors which don't already
|
||||||
// jump to a landing pad, and so can safely jump to the fallthrough?
|
// jump to a landing pad, and so can safely jump to the fallthrough?
|
||||||
} else {
|
} else if (MBB->isSuccessor(&*FallThrough)) {
|
||||||
// Rewrite all predecessors of the old block to go to the fallthrough
|
// Rewrite all predecessors of the old block to go to the fallthrough
|
||||||
// instead.
|
// instead.
|
||||||
while (!MBB->pred_empty()) {
|
while (!MBB->pred_empty()) {
|
||||||
|
@ -24,7 +24,7 @@ entry:
|
|||||||
|
|
||||||
lpad: ; preds = %entry
|
lpad: ; preds = %entry
|
||||||
; CHECK-EL: # %lpad
|
; CHECK-EL: # %lpad
|
||||||
; CHECK-EL: beq $5
|
; CHECK-EL: bne $5
|
||||||
|
|
||||||
%exn.val = landingpad { i8*, i32 }
|
%exn.val = landingpad { i8*, i32 }
|
||||||
cleanup
|
cleanup
|
||||||
|
@ -4,14 +4,14 @@ target triple = "sparc64-unknown-linux-gnu"
|
|||||||
|
|
||||||
define void @f() align 2 {
|
define void @f() align 2 {
|
||||||
entry:
|
entry:
|
||||||
; CHECK: %xcc, .LBB0_1
|
; CHECK: %xcc, .LBB0_2
|
||||||
%cmp = icmp eq i64 undef, 0
|
%cmp = icmp eq i64 undef, 0
|
||||||
br i1 %cmp, label %targetblock, label %cond.false
|
br i1 %cmp, label %targetblock, label %cond.false
|
||||||
|
|
||||||
cond.false:
|
cond.false:
|
||||||
unreachable
|
unreachable
|
||||||
|
|
||||||
; CHECK: .LBB0_1: ! %targetblock
|
; CHECK: .LBB0_2: ! %targetblock
|
||||||
targetblock:
|
targetblock:
|
||||||
br i1 undef, label %cond.false.i83, label %exit.i85
|
br i1 undef, label %cond.false.i83, label %exit.i85
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ declare double @foo(double) nounwind readnone
|
|||||||
|
|
||||||
define void @t(i32 %c, double %b) {
|
define void @t(i32 %c, double %b) {
|
||||||
entry:
|
entry:
|
||||||
|
; CHECK: cmp r0, #0
|
||||||
%cmp1 = icmp ne i32 %c, 0
|
%cmp1 = icmp ne i32 %c, 0
|
||||||
br i1 %cmp1, label %bb3, label %bb1
|
br i1 %cmp1, label %bb3, label %bb1
|
||||||
|
|
||||||
@ -23,8 +24,7 @@ bb7: ; preds = %bb3
|
|||||||
br i1 %cmp3, label %bb11, label %bb9
|
br i1 %cmp3, label %bb11, label %bb9
|
||||||
|
|
||||||
bb9: ; preds = %bb7
|
bb9: ; preds = %bb7
|
||||||
; CHECK: cmp r0, #0
|
; CHECK: cbnz
|
||||||
; CHECK-NEXT: cbnz
|
|
||||||
%0 = tail call double @foo(double %b) nounwind readnone ; <double> [#uses=0]
|
%0 = tail call double @foo(double %b) nounwind readnone ; <double> [#uses=0]
|
||||||
br label %bb11
|
br label %bb11
|
||||||
|
|
||||||
|
@ -17,31 +17,13 @@
|
|||||||
|
|
||||||
define i32 @t(i32 %type) optsize {
|
define i32 @t(i32 %type) optsize {
|
||||||
entry:
|
entry:
|
||||||
br i1 undef, label %if.then, label %if.else
|
|
||||||
|
|
||||||
if.then:
|
|
||||||
unreachable
|
|
||||||
|
|
||||||
if.else:
|
|
||||||
br i1 undef, label %if.then15, label %if.else18
|
|
||||||
|
|
||||||
if.then15:
|
|
||||||
unreachable
|
|
||||||
|
|
||||||
if.else18:
|
|
||||||
switch i32 %type, label %if.else173 [
|
switch i32 %type, label %if.else173 [
|
||||||
i32 3, label %if.then115
|
i32 13, label %if.then115
|
||||||
i32 1, label %if.then102
|
i32 6, label %if.then102
|
||||||
]
|
]
|
||||||
|
|
||||||
if.then102:
|
if.then102:
|
||||||
br i1 undef, label %cond.true10.i, label %t.exit
|
br label %if.then115
|
||||||
|
|
||||||
cond.true10.i:
|
|
||||||
br label %t.exit
|
|
||||||
|
|
||||||
t.exit:
|
|
||||||
unreachable
|
|
||||||
|
|
||||||
if.then115:
|
if.then115:
|
||||||
br i1 undef, label %if.else163, label %if.else145
|
br i1 undef, label %if.else163, label %if.else145
|
||||||
@ -62,4 +44,3 @@ if.else173:
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare hidden fastcc %struct.hc* @foo(%struct.hc* nocapture, i32) nounwind optsize
|
declare hidden fastcc %struct.hc* @foo(%struct.hc* nocapture, i32) nounwind optsize
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
; RUN: llc -mtriple=x86_64-scei-ps4 < %s | FileCheck -check-prefix=PS4 %s
|
; RUN: llc -mtriple=x86_64-scei-ps4 < %s | FileCheck -check-prefix=PS4 %s
|
||||||
|
|
||||||
; X64_DARWIN: orq
|
; X64_DARWIN: orq
|
||||||
|
; X64_DARWIN-NEXT: jne
|
||||||
; X64_DARWIN-NEXT: %bb8.i329
|
; X64_DARWIN-NEXT: %bb8.i329
|
||||||
|
|
||||||
; X64_LINUX: orq %rax, %rcx
|
; X64_LINUX: orq %rax, %rcx
|
||||||
|
; X64_LINUX-NEXT: jne
|
||||||
; X64_LINUX-NEXT: %bb8.i329
|
; X64_LINUX-NEXT: %bb8.i329
|
||||||
|
|
||||||
; X64_WINDOWS: orq %rax, %rcx
|
; X64_WINDOWS: orq %rax, %rcx
|
||||||
|
34
test/CodeGen/X86/tail-merge-unreachable.ll
Normal file
34
test/CodeGen/X86/tail-merge-unreachable.ll
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
; RUN: llc -mtriple=x86_64-linux-gnu %s -o - -verify-machineinstrs | FileCheck %s
|
||||||
|
|
||||||
|
define i32 @tail_merge_unreachable(i32 %i) {
|
||||||
|
entry:
|
||||||
|
br i1 undef, label %sw, label %end
|
||||||
|
sw:
|
||||||
|
switch i32 %i, label %end [
|
||||||
|
i32 99, label %sw.bb
|
||||||
|
i32 98, label %sw.bb
|
||||||
|
i32 101, label %sw.bb
|
||||||
|
i32 97, label %sw.bb2
|
||||||
|
i32 96, label %sw.bb2
|
||||||
|
i32 100, label %sw.bb2
|
||||||
|
]
|
||||||
|
sw.bb:
|
||||||
|
unreachable
|
||||||
|
sw.bb2:
|
||||||
|
unreachable
|
||||||
|
end:
|
||||||
|
%p = phi i32 [ 1, %sw ], [ 0, %entry ]
|
||||||
|
ret i32 %p
|
||||||
|
|
||||||
|
; CHECK-LABEL: tail_merge_unreachable:
|
||||||
|
; Range Check
|
||||||
|
; CHECK: addl $-96
|
||||||
|
; CHECK: cmpl $5
|
||||||
|
; CHECK: jbe [[JUMP_TABLE_BLOCK:[.][A-Za-z0-9_]+]]
|
||||||
|
; CHECK: retq
|
||||||
|
; CHECK: [[JUMP_TABLE_BLOCK]]:
|
||||||
|
; CHECK: btl
|
||||||
|
; CHECK: jae [[UNREACHABLE_BLOCK:[.][A-Za-z0-9_]+]]
|
||||||
|
; CHECK [[UNREACHABLE_BLOCK]]:
|
||||||
|
; CHECK: .Lfunc_end0
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user