mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-20 12:31:40 +00:00
Revert r143214; it's breaking a bunch of stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143265 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6f3ddef7c5
commit
09c3253d30
@ -416,55 +416,39 @@ static Value *ThreadCmpOverSelect(CmpInst::Predicate Pred, Value *LHS,
|
|||||||
}
|
}
|
||||||
assert(isa<SelectInst>(LHS) && "Not comparing with a select instruction!");
|
assert(isa<SelectInst>(LHS) && "Not comparing with a select instruction!");
|
||||||
SelectInst *SI = cast<SelectInst>(LHS);
|
SelectInst *SI = cast<SelectInst>(LHS);
|
||||||
Value *Cond = SI->getCondition();
|
|
||||||
Value *TV = SI->getTrueValue();
|
|
||||||
Value *FV = SI->getFalseValue();
|
|
||||||
|
|
||||||
// Now that we have "cmp select(Cond, TV, FV), RHS", analyse it.
|
// Now that we have "cmp select(Cond, TV, FV), RHS", analyse it.
|
||||||
// Does "cmp TV, RHS" simplify?
|
// Does "cmp TV, RHS" simplify?
|
||||||
Value *TCmp = SimplifyCmpInst(Pred, TV, RHS, TD, DT, MaxRecurse);
|
if (Value *TCmp = SimplifyCmpInst(Pred, SI->getTrueValue(), RHS, TD, DT,
|
||||||
if (!TCmp) {
|
MaxRecurse)) {
|
||||||
// It didn't simplify. However if "cmp TV, RHS" is equal to the select
|
// It does! Does "cmp FV, RHS" simplify?
|
||||||
// condition itself then we can replace it with 'true'.
|
if (Value *FCmp = SimplifyCmpInst(Pred, SI->getFalseValue(), RHS, TD, DT,
|
||||||
if (match(Cond, m_ICmp(Pred, m_Specific(TV), m_Specific(RHS))))
|
MaxRecurse)) {
|
||||||
TCmp = getTrue(Cond->getType());
|
// It does! If they simplified to the same value, then use it as the
|
||||||
|
// result of the original comparison.
|
||||||
|
if (TCmp == FCmp)
|
||||||
|
return TCmp;
|
||||||
|
Value *Cond = SI->getCondition();
|
||||||
|
// If the false value simplified to false, then the result of the compare
|
||||||
|
// is equal to "Cond && TCmp". This also catches the case when the false
|
||||||
|
// value simplified to false and the true value to true, returning "Cond".
|
||||||
|
if (match(FCmp, m_Zero()))
|
||||||
|
if (Value *V = SimplifyAndInst(Cond, TCmp, TD, DT, MaxRecurse))
|
||||||
|
return V;
|
||||||
|
// If the true value simplified to true, then the result of the compare
|
||||||
|
// is equal to "Cond || FCmp".
|
||||||
|
if (match(TCmp, m_One()))
|
||||||
|
if (Value *V = SimplifyOrInst(Cond, FCmp, TD, DT, MaxRecurse))
|
||||||
|
return V;
|
||||||
|
// Finally, if the false value simplified to true and the true value to
|
||||||
|
// false, then the result of the compare is equal to "!Cond".
|
||||||
|
if (match(FCmp, m_One()) && match(TCmp, m_Zero()))
|
||||||
|
if (Value *V =
|
||||||
|
SimplifyXorInst(Cond, Constant::getAllOnesValue(Cond->getType()),
|
||||||
|
TD, DT, MaxRecurse))
|
||||||
|
return V;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!TCmp)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Does "cmp FV, RHS" simplify?
|
|
||||||
Value *FCmp = SimplifyCmpInst(Pred, FV, RHS, TD, DT, MaxRecurse);
|
|
||||||
if (!FCmp) {
|
|
||||||
// It didn't simplify. However if "cmp FV, RHS" is equal to the select
|
|
||||||
// condition itself then we can replace it with 'false'.
|
|
||||||
if (match(Cond, m_ICmp(Pred, m_Specific(FV), m_Specific(RHS))))
|
|
||||||
FCmp = getFalse(Cond->getType());
|
|
||||||
}
|
|
||||||
if (!FCmp)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// If both sides simplified to the same value, then use it as the result of
|
|
||||||
// the original comparison.
|
|
||||||
if (TCmp == FCmp)
|
|
||||||
return TCmp;
|
|
||||||
// If the false value simplified to false, then the result of the compare
|
|
||||||
// is equal to "Cond && TCmp". This also catches the case when the false
|
|
||||||
// value simplified to false and the true value to true, returning "Cond".
|
|
||||||
if (match(FCmp, m_Zero()))
|
|
||||||
if (Value *V = SimplifyAndInst(Cond, TCmp, TD, DT, MaxRecurse))
|
|
||||||
return V;
|
|
||||||
// If the true value simplified to true, then the result of the compare
|
|
||||||
// is equal to "Cond || FCmp".
|
|
||||||
if (match(TCmp, m_One()))
|
|
||||||
if (Value *V = SimplifyOrInst(Cond, FCmp, TD, DT, MaxRecurse))
|
|
||||||
return V;
|
|
||||||
// Finally, if the false value simplified to true and the true value to
|
|
||||||
// false, then the result of the compare is equal to "!Cond".
|
|
||||||
if (match(FCmp, m_One()) && match(TCmp, m_Zero()))
|
|
||||||
if (Value *V =
|
|
||||||
SimplifyXorInst(Cond, Constant::getAllOnesValue(Cond->getType()),
|
|
||||||
TD, DT, MaxRecurse))
|
|
||||||
return V;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -204,15 +204,6 @@ define i1 @select4(i1 %cond) {
|
|||||||
; CHECK: ret i1 %cond
|
; CHECK: ret i1 %cond
|
||||||
}
|
}
|
||||||
|
|
||||||
define i1 @select5(i32 %x) {
|
|
||||||
; CHECK: @select5
|
|
||||||
%c = icmp eq i32 %x, 0
|
|
||||||
%s = select i1 %c, i32 1, i32 %x
|
|
||||||
%c2 = icmp eq i32 %s, 0
|
|
||||||
ret i1 %c2
|
|
||||||
; CHECK: ret i1 false
|
|
||||||
}
|
|
||||||
|
|
||||||
define i1 @urem1(i32 %X, i32 %Y) {
|
define i1 @urem1(i32 %X, i32 %Y) {
|
||||||
; CHECK: @urem1
|
; CHECK: @urem1
|
||||||
%A = urem i32 %X, %Y
|
%A = urem i32 %X, %Y
|
||||||
|
Loading…
x
Reference in New Issue
Block a user