mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-23 02:44:32 +00:00
ARM: avoid duplicating branches during constant islands.
We were using a naive heuristic to determine whether a basic block already had an unconditional branch at the end. This mostly corresponded to reality (assuming branches got optimised) because there's not much point in a branch to the next block, but could go wrong. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221904 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5bd311bf17
commit
064da63fcb
@ -275,6 +275,7 @@ namespace {
|
||||
|
||||
private:
|
||||
void doInitialPlacement(std::vector<MachineInstr*> &CPEMIs);
|
||||
bool BBHasFallthrough(MachineBasicBlock *MBB);
|
||||
CPEntry *findConstPoolEntry(unsigned CPI, const MachineInstr *CPEMI);
|
||||
unsigned getCPELogAlign(const MachineInstr *CPEMI);
|
||||
void scanFunctionJumpTables();
|
||||
@ -566,7 +567,7 @@ ARMConstantIslands::doInitialPlacement(std::vector<MachineInstr*> &CPEMIs) {
|
||||
|
||||
/// BBHasFallthrough - Return true if the specified basic block can fallthrough
|
||||
/// into the block immediately after it.
|
||||
static bool BBHasFallthrough(MachineBasicBlock *MBB) {
|
||||
bool ARMConstantIslands::BBHasFallthrough(MachineBasicBlock *MBB) {
|
||||
// Get the next machine basic block in the function.
|
||||
MachineFunction::iterator MBBI = MBB;
|
||||
// Can't fall off end of function.
|
||||
@ -574,12 +575,15 @@ static bool BBHasFallthrough(MachineBasicBlock *MBB) {
|
||||
return false;
|
||||
|
||||
MachineBasicBlock *NextBB = std::next(MBBI);
|
||||
for (MachineBasicBlock::succ_iterator I = MBB->succ_begin(),
|
||||
E = MBB->succ_end(); I != E; ++I)
|
||||
if (*I == NextBB)
|
||||
return true;
|
||||
if (std::find(MBB->succ_begin(), MBB->succ_end(), NextBB) == MBB->succ_end())
|
||||
return false;
|
||||
|
||||
return false;
|
||||
// Try to analyze the end of the block. A potential fallthrough may already
|
||||
// have an unconditional branch for whatever reason.
|
||||
MachineBasicBlock *TBB, *FBB;
|
||||
SmallVector<MachineOperand, 4> Cond;
|
||||
bool TooDifficult = TII->AnalyzeBranch(*MBB, TBB, FBB, Cond);
|
||||
return TooDifficult || FBB == nullptr;
|
||||
}
|
||||
|
||||
/// findConstPoolEntry - Given the constpool index and CONSTPOOL_ENTRY MI,
|
||||
|
25
test/CodeGen/ARM/constant-islands.ll
Normal file
25
test/CodeGen/ARM/constant-islands.ll
Normal file
@ -0,0 +1,25 @@
|
||||
; RUN: llc -mtriple=thumbv7-linux-gnueabihf -O0 -fast-isel=0 -o - %s | FileCheck %s
|
||||
|
||||
define void @test_no_duplicate_branches(float %in) {
|
||||
; CHECK-LABEL: test_no_duplicate_branches:
|
||||
; CHECK: vldr {{s[0-9]+}}, [[CONST:\.LCPI[0-9]+_[0-9]+]]
|
||||
; CHECK: b .LBB
|
||||
; CHECK-NOT: b .LBB
|
||||
; CHECK: [[CONST]]:
|
||||
; CHECK-NEXT: .long 1150963712
|
||||
|
||||
%tst = fcmp oeq float %in, 1234.5
|
||||
|
||||
%chain = zext i1 %tst to i32
|
||||
|
||||
br i1 %tst, label %true, label %false
|
||||
|
||||
true:
|
||||
call i32 @llvm.arm.space(i32 2000, i32 undef)
|
||||
ret void
|
||||
|
||||
false:
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @llvm.arm.space(i32, i32)
|
Loading…
x
Reference in New Issue
Block a user