mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-04 18:38:05 +00:00
Implement some more interesting select sccp cases. This implements:
test/Regression/Transforms/SCCP/select.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26049 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d27460f291
commit
fe243ebb64
@ -241,6 +241,11 @@ private:
|
|||||||
else if (IV.getConstant() != MergeWithV.getConstant())
|
else if (IV.getConstant() != MergeWithV.getConstant())
|
||||||
markOverdefined(IV, V);
|
markOverdefined(IV, V);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void mergeInValue(Value *V, LatticeVal &MergeWithV) {
|
||||||
|
return mergeInValue(ValueState[V], V, MergeWithV);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// getValueState - Return the LatticeVal object that corresponds to the value.
|
// getValueState - Return the LatticeVal object that corresponds to the value.
|
||||||
// This function is necessary because not all values should start out in the
|
// This function is necessary because not all values should start out in the
|
||||||
@ -589,23 +594,38 @@ void SCCPSolver::visitCastInst(CastInst &I) {
|
|||||||
|
|
||||||
void SCCPSolver::visitSelectInst(SelectInst &I) {
|
void SCCPSolver::visitSelectInst(SelectInst &I) {
|
||||||
LatticeVal &CondValue = getValueState(I.getCondition());
|
LatticeVal &CondValue = getValueState(I.getCondition());
|
||||||
if (CondValue.isOverdefined())
|
if (CondValue.isUndefined())
|
||||||
markOverdefined(&I);
|
return;
|
||||||
else if (CondValue.isConstant()) {
|
if (CondValue.isConstant()) {
|
||||||
|
Value *InVal = 0;
|
||||||
if (CondValue.getConstant() == ConstantBool::True) {
|
if (CondValue.getConstant() == ConstantBool::True) {
|
||||||
LatticeVal &Val = getValueState(I.getTrueValue());
|
mergeInValue(&I, getValueState(I.getTrueValue()));
|
||||||
if (Val.isOverdefined())
|
return;
|
||||||
markOverdefined(&I);
|
|
||||||
else if (Val.isConstant())
|
|
||||||
markConstant(&I, Val.getConstant());
|
|
||||||
} else if (CondValue.getConstant() == ConstantBool::False) {
|
} else if (CondValue.getConstant() == ConstantBool::False) {
|
||||||
LatticeVal &Val = getValueState(I.getFalseValue());
|
mergeInValue(&I, getValueState(I.getFalseValue()));
|
||||||
if (Val.isOverdefined())
|
return;
|
||||||
markOverdefined(&I);
|
}
|
||||||
else if (Val.isConstant())
|
}
|
||||||
markConstant(&I, Val.getConstant());
|
|
||||||
} else
|
// Otherwise, the condition is overdefined or a constant we can't evaluate.
|
||||||
markOverdefined(&I);
|
// See if we can produce something better than overdefined based on the T/F
|
||||||
|
// value.
|
||||||
|
LatticeVal &TVal = getValueState(I.getTrueValue());
|
||||||
|
LatticeVal &FVal = getValueState(I.getFalseValue());
|
||||||
|
|
||||||
|
// select ?, C, C -> C.
|
||||||
|
if (TVal.isConstant() && FVal.isConstant() &&
|
||||||
|
TVal.getConstant() == FVal.getConstant()) {
|
||||||
|
markConstant(&I, FVal.getConstant());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TVal.isUndefined()) { // select ?, undef, X -> X.
|
||||||
|
mergeInValue(&I, FVal);
|
||||||
|
} else if (FVal.isUndefined()) { // select ?, X, undef -> X.
|
||||||
|
mergeInValue(&I, TVal);
|
||||||
|
} else {
|
||||||
|
markOverdefined(&I);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user