mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 02:31:09 +00:00
R600: Fix a crash in the AMDILCFGStrucurizer
The ifPatternMatch() function was not correctly reporting the number of matches in some cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195030 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ef37e453c4
commit
44248e0f63
@ -1005,13 +1005,14 @@ int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
assert(isCondBranch(BranchMI));
|
assert(isCondBranch(BranchMI));
|
||||||
|
int NumMatch = 0;
|
||||||
|
|
||||||
MachineBasicBlock *TrueMBB = getTrueBranch(BranchMI);
|
MachineBasicBlock *TrueMBB = getTrueBranch(BranchMI);
|
||||||
serialPatternMatch(TrueMBB);
|
NumMatch += serialPatternMatch(TrueMBB);
|
||||||
ifPatternMatch(TrueMBB);
|
NumMatch += ifPatternMatch(TrueMBB);
|
||||||
MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI);
|
MachineBasicBlock *FalseMBB = getFalseBranch(MBB, BranchMI);
|
||||||
serialPatternMatch(FalseMBB);
|
NumMatch += serialPatternMatch(FalseMBB);
|
||||||
ifPatternMatch(FalseMBB);
|
NumMatch += ifPatternMatch(FalseMBB);
|
||||||
MachineBasicBlock *LandBlk;
|
MachineBasicBlock *LandBlk;
|
||||||
int Cloned = 0;
|
int Cloned = 0;
|
||||||
|
|
||||||
@ -1040,7 +1041,7 @@ int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) {
|
|||||||
&& isSameloopDetachedContbreak(FalseMBB, TrueMBB)) {
|
&& isSameloopDetachedContbreak(FalseMBB, TrueMBB)) {
|
||||||
LandBlk = *TrueMBB->succ_begin();
|
LandBlk = *TrueMBB->succ_begin();
|
||||||
} else {
|
} else {
|
||||||
return handleJumpintoIf(MBB, TrueMBB, FalseMBB);
|
return NumMatch + handleJumpintoIf(MBB, TrueMBB, FalseMBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// improveSimpleJumpinfoIf can handle the case where landBlk == NULL but the
|
// improveSimpleJumpinfoIf can handle the case where landBlk == NULL but the
|
||||||
@ -1068,7 +1069,7 @@ int AMDGPUCFGStructurizer::ifPatternMatch(MachineBasicBlock *MBB) {
|
|||||||
|
|
||||||
numClonedBlock += Cloned;
|
numClonedBlock += Cloned;
|
||||||
|
|
||||||
return 1 + Cloned;
|
return 1 + Cloned + NumMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AMDGPUCFGStructurizer::loopendPatternMatch() {
|
int AMDGPUCFGStructurizer::loopendPatternMatch() {
|
||||||
|
62
test/CodeGen/R600/structurize1.ll
Normal file
62
test/CodeGen/R600/structurize1.ll
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
; RUN: llc < %s -march=r600 -mattr=disable-ifcvt -mcpu=redwood | FileCheck %s
|
||||||
|
|
||||||
|
; This tests for abug where the AMDILCFGStructurizer was crashing on loops
|
||||||
|
; like this:
|
||||||
|
;
|
||||||
|
; for (i = 0; i < x; i++) {
|
||||||
|
; if (cond0) {
|
||||||
|
; if (cond1) {
|
||||||
|
;
|
||||||
|
; } else {
|
||||||
|
;
|
||||||
|
; }
|
||||||
|
; if (cond2) {
|
||||||
|
;
|
||||||
|
; }
|
||||||
|
; }
|
||||||
|
; }
|
||||||
|
|
||||||
|
; CHECK-LABEL: @if_inside_loop
|
||||||
|
; CHECK: LOOP_START_DX10
|
||||||
|
; CHECK: END_LOOP
|
||||||
|
define void @if_inside_loop(i32 addrspace(1)* %out, i32 %a, i32 %b, i32 %c, i32 %d) {
|
||||||
|
entry:
|
||||||
|
br label %for.body
|
||||||
|
|
||||||
|
for.body:
|
||||||
|
%0 = phi i32 [0, %entry], [%inc, %for.inc]
|
||||||
|
%val = phi i32 [0, %entry], [%val.for.inc, %for.inc]
|
||||||
|
%inc = add i32 %0, 1
|
||||||
|
%1 = icmp ult i32 10, %a
|
||||||
|
br i1 %1, label %for.inc, label %if.then
|
||||||
|
|
||||||
|
if.then:
|
||||||
|
%2 = icmp ne i32 0, %b
|
||||||
|
br i1 %2, label %if.then.true, label %if.then.false
|
||||||
|
|
||||||
|
if.then.true:
|
||||||
|
%3 = add i32 %a, %val
|
||||||
|
br label %if
|
||||||
|
|
||||||
|
if.then.false:
|
||||||
|
%4 = mul i32 %a, %val
|
||||||
|
br label %if
|
||||||
|
|
||||||
|
if:
|
||||||
|
%val.if = phi i32 [%3, %if.then.true], [%4, %if.then.false]
|
||||||
|
%5 = icmp ne i32 0, %c
|
||||||
|
br i1 %5, label %if.true, label %for.inc
|
||||||
|
|
||||||
|
if.true:
|
||||||
|
%6 = add i32 %a, %val.if
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc:
|
||||||
|
%val.for.inc = phi i32 [%val, %for.body], [%val.if, %if], [%6, %if.true]
|
||||||
|
%7 = icmp ne i32 0, %d
|
||||||
|
br i1 %7, label %for.body, label %exit
|
||||||
|
|
||||||
|
exit:
|
||||||
|
store i32 %val.for.inc, i32 addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user