Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Analysis/InstructionSimplify.cpp
Show First 20 Lines • Show All 4,112 Lines • ▼ Show 20 Lines | static Value *SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, | ||||
if (Cond->getType() == TrueVal->getType() && | if (Cond->getType() == TrueVal->getType() && | ||||
match(TrueVal, m_One()) && match(FalseVal, m_ZeroInt())) | match(TrueVal, m_One()) && match(FalseVal, m_ZeroInt())) | ||||
return Cond; | return Cond; | ||||
// select ?, X, X -> X | // select ?, X, X -> X | ||||
if (TrueVal == FalseVal) | if (TrueVal == FalseVal) | ||||
return TrueVal; | return TrueVal; | ||||
// If the true or false value is undef, we can fold to the other value as | |||||
// long as the other value isn't poison. | |||||
// select ?, undef, X -> X | |||||
if (isa<UndefValue>(TrueVal) && | |||||
craig.topper: Should I be passing CxtI and DT here? I based this off the code in SimplifyInsertElementInst… | |||||
Not Done ReplyInline ActionsYes, you can; it's correct to do so. nlopes: Yes, you can; it's correct to do so.
The only issue is that `SimplifySelectInst()` doesn't seem… | |||||
isGuaranteedNotToBeUndefOrPoison(FalseVal, Q.CxtI, Q.DT)) | |||||
return FalseVal; | |||||
// select ?, X, undef -> X | |||||
if (isa<UndefValue>(FalseVal) && | |||||
isGuaranteedNotToBeUndefOrPoison(TrueVal, Q.CxtI, Q.DT)) | |||||
return TrueVal; | |||||
// Deal with partial undef vector constants: select ?, VecC, VecC' --> VecC'' | // Deal with partial undef vector constants: select ?, VecC, VecC' --> VecC'' | ||||
Constant *TrueC, *FalseC; | Constant *TrueC, *FalseC; | ||||
if (TrueVal->getType()->isVectorTy() && match(TrueVal, m_Constant(TrueC)) && | if (TrueVal->getType()->isVectorTy() && match(TrueVal, m_Constant(TrueC)) && | ||||
match(FalseVal, m_Constant(FalseC))) { | match(FalseVal, m_Constant(FalseC))) { | ||||
unsigned NumElts = cast<VectorType>(TrueC->getType())->getNumElements(); | unsigned NumElts = cast<VectorType>(TrueC->getType())->getNumElements(); | ||||
SmallVector<Constant *, 16> NewC; | SmallVector<Constant *, 16> NewC; | ||||
for (unsigned i = 0; i != NumElts; ++i) { | for (unsigned i = 0; i != NumElts; ++i) { | ||||
// Bail out on incomplete vector constants. | // Bail out on incomplete vector constants. | ||||
▲ Show 20 Lines • Show All 1,657 Lines • Show Last 20 Lines |
Should I be passing CxtI and DT here? I based this off the code in SimplifyInsertElementInst, but maybe i should have based it off of SimplifyFreezeInst?