mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
8eab75f390
There are 2 changes relative to the previous version of the patch: 1) For the "simple" if-conversion case, there's no need to worry about RemoveExtraEdges not handling an unanalyzable branch. Predicated terminators are ignored in this context, so RemoveExtraEdges does the right thing. This might break someday if we ever treat indirect branches (BRIND) as predicable, but for now, I just removed this part of the patch, because in the case where we do not add an unconditional branch, we rely on keeping the fall-through edge to CvtBBI (which is empty after this transformation). The change relative to the previous patch is: @@ -1036,10 +1036,6 @@ IterIfcvt = false; } - // RemoveExtraEdges won't work if the block has an unanalyzable branch, - // which is typically the case for IfConvertSimple, so explicitly remove - // CvtBBI as a successor. - BBI.BB->removeSuccessor(CvtBBI->BB); RemoveExtraEdges(BBI); // Update block info. BB can be iteratively if-converted. 2) My patch exposed a bug in the code for merging the tail of a "diamond", which had previously never been exercised. The code was simply checking that the tail had a single predecessor, but there was a case in MultiSource/Benchmarks/VersaBench/dbms where that single predecessor was neither edge of the diamond. I added the following change to check for that: @@ -1276,7 +1276,18 @@ // tail, add a unconditional branch to it. if (TailBB) { BBInfo TailBBI = BBAnalysis[TailBB->getNumber()]; - if (TailBB->pred_size() == 1 && !TailBBI.HasFallThrough) { + bool CanMergeTail = !TailBBI.HasFallThrough; + // There may still be a fall-through edge from BBI1 or BBI2 to TailBB; + // check if there are any other predecessors besides those. + unsigned NumPreds = TailBB->pred_size(); + if (NumPreds > 1) + CanMergeTail = false; + else if (NumPreds == 1 && CanMergeTail) { + MachineBasicBlock::pred_iterator PI = TailBB->pred_begin(); + if (*PI != BBI1->BB && *PI != BBI2->BB) + CanMergeTail = false; + } + if (CanMergeTail) { MergeBlocks(BBI, TailBBI); TailBBI.IsDone = true; } else { With these fixes, I was able to run all the SingleSource and MultiSource tests successfully. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107110 91177308-0d34-0410-b5e6-96231b3b80d8
33 lines
1.1 KiB
LLVM
33 lines
1.1 KiB
LLVM
; RUN: llc < %s -mtriple=thumbv7-apple-darwin | FileCheck %s
|
|
|
|
; There shouldn't be a unconditional branch at end of bb52.
|
|
; rdar://7184787
|
|
|
|
@posed = external global i64 ; <i64*> [#uses=1]
|
|
|
|
define i1 @ab_bb52(i64 %.reload78, i64* %.out, i64* %.out1) nounwind {
|
|
newFuncRoot:
|
|
br label %bb52
|
|
|
|
bb52.bb55_crit_edge.exitStub: ; preds = %bb52
|
|
store i64 %0, i64* %.out
|
|
store i64 %2, i64* %.out1
|
|
ret i1 true
|
|
|
|
bb52.bb53_crit_edge.exitStub: ; preds = %bb52
|
|
store i64 %0, i64* %.out
|
|
store i64 %2, i64* %.out1
|
|
ret i1 false
|
|
|
|
bb52: ; preds = %newFuncRoot
|
|
; CHECK: movne
|
|
; CHECK: moveq
|
|
; CHECK: pop
|
|
; CHECK-NEXT: @ BB#1:
|
|
%0 = load i64* @posed, align 4 ; <i64> [#uses=3]
|
|
%1 = sub i64 %0, %.reload78 ; <i64> [#uses=1]
|
|
%2 = ashr i64 %1, 1 ; <i64> [#uses=3]
|
|
%3 = icmp eq i64 %2, 0 ; <i1> [#uses=1]
|
|
br i1 %3, label %bb52.bb55_crit_edge.exitStub, label %bb52.bb53_crit_edge.exitStub
|
|
}
|