mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Remove dyn_cast + dereference pattern by replacing it with a cast and changing
the safety check to look for the same type we're going to actually cast to. Fixes PR13180! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e7f702fc2d
commit
edb5842b7c
@ -156,7 +156,7 @@ static bool isProfitableToFoldUnconditional(BranchInst *SI1,
|
|||||||
isa<PHINode>(BBI); ++BBI) {
|
isa<PHINode>(BBI); ++BBI) {
|
||||||
PHINode *PN = cast<PHINode>(BBI);
|
PHINode *PN = cast<PHINode>(BBI);
|
||||||
if (PN->getIncomingValueForBlock(SI1BB) != Cond ||
|
if (PN->getIncomingValueForBlock(SI1BB) != Cond ||
|
||||||
!isa<Constant>(PN->getIncomingValueForBlock(SI2BB)))
|
!isa<ConstantInt>(PN->getIncomingValueForBlock(SI2BB)))
|
||||||
return false;
|
return false;
|
||||||
PhiNodes.push_back(PN);
|
PhiNodes.push_back(PN);
|
||||||
}
|
}
|
||||||
@ -1782,7 +1782,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) {
|
|||||||
} else {
|
} else {
|
||||||
// Update PHI nodes in the common successors.
|
// Update PHI nodes in the common successors.
|
||||||
for (unsigned i = 0, e = PHIs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = PHIs.size(); i != e; ++i) {
|
||||||
ConstantInt *PBI_C = dyn_cast<ConstantInt>(
|
ConstantInt *PBI_C = cast<ConstantInt>(
|
||||||
PHIs[i]->getIncomingValueForBlock(PBI->getParent()));
|
PHIs[i]->getIncomingValueForBlock(PBI->getParent()));
|
||||||
assert(PBI_C->getType()->isIntegerTy(1));
|
assert(PBI_C->getType()->isIntegerTy(1));
|
||||||
Instruction *MergedCond = 0;
|
Instruction *MergedCond = 0;
|
||||||
|
@ -50,3 +50,21 @@ c:
|
|||||||
%o2 = phi i1 [ false, %a ], [ %phitmp, %b ], [ false, %entry ]
|
%o2 = phi i1 [ false, %a ], [ %phitmp, %b ], [ false, %entry ]
|
||||||
ret i1 %o2
|
ret i1 %o2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; PR13180
|
||||||
|
define void @pr13180(i8 %p) {
|
||||||
|
entry:
|
||||||
|
%tobool = icmp eq i8 %p, 0
|
||||||
|
br i1 %tobool, label %cond.false, label %cond.true
|
||||||
|
|
||||||
|
cond.true: ; preds = %entry
|
||||||
|
br label %cond.end
|
||||||
|
|
||||||
|
cond.false: ; preds = %entry
|
||||||
|
%phitmp = icmp eq i8 %p, 0
|
||||||
|
br label %cond.end
|
||||||
|
|
||||||
|
cond.end: ; preds = %cond.false, %cond.true
|
||||||
|
%cond = phi i1 [ undef, %cond.true ], [ %phitmp, %cond.false ]
|
||||||
|
unreachable
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user