mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 16:29:20 +00:00
[InstCombine] Simplify the logic from r219067 using ValueTracking
Joerg suggested on IRC that I look at generalizing the logic from r219067 to handle more general redundancies (like removing an assume(x > 3) dominated by an assume(x > 5)). The way to do this would be to ask ValueTracking to determine the value of the i1 argument. It turns out that ValueTracking is not very good at this right now (although it does get the trivial redundancy case) because it does not understand ICmps. Nevertheless, the resulting code in InstCombine is simpler than r219067, so we might as well do it now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219070 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3cdf75c5cf
commit
bda7a45f8e
@ -1020,18 +1020,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
|
||||
// If there is a dominating assume with the same condition as this one,
|
||||
// then this one is redundant, and should be removed.
|
||||
if (DT) {
|
||||
for (User *U : IIOperand->users()) {
|
||||
Instruction *User = dyn_cast<Instruction>(U);
|
||||
if (!User || User == II)
|
||||
continue;
|
||||
|
||||
if (match(User,
|
||||
m_Intrinsic<Intrinsic::assume>(m_Specific(IIOperand))) &&
|
||||
DT->dominates(User, II))
|
||||
return EraseInstFromFunction(*II);
|
||||
}
|
||||
}
|
||||
APInt KnownZero(1, 0), KnownOne(1, 0);
|
||||
computeKnownBits(IIOperand, KnownZero, KnownOne, 0, II);
|
||||
if (KnownOne.isAllOnesValue())
|
||||
return EraseInstFromFunction(*II);
|
||||
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user