Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
Show First 20 Lines • Show All 4,906 Lines • ▼ Show 20 Lines | case Intrinsic::smul_with_overflow: | ||||
// X * 0 -> { 0, false } | // X * 0 -> { 0, false } | ||||
if (match(Op0, m_Zero()) || match(Op1, m_Zero())) | if (match(Op0, m_Zero()) || match(Op1, m_Zero())) | ||||
return Constant::getNullValue(ReturnType); | return Constant::getNullValue(ReturnType); | ||||
// undef * X -> { 0, false } | // undef * X -> { 0, false } | ||||
// X * undef -> { 0, false } | // X * undef -> { 0, false } | ||||
if (match(Op0, m_Undef()) || match(Op1, m_Undef())) | if (match(Op0, m_Undef()) || match(Op1, m_Undef())) | ||||
return Constant::getNullValue(ReturnType); | return Constant::getNullValue(ReturnType); | ||||
break; | break; | ||||
case Intrinsic::uadd_sat: | |||||
// sat(MAX + X) -> MAX | |||||
// sat(X + MAX) -> MAX | |||||
if (match(Op0, m_AllOnes()) || match(Op1, m_AllOnes())) | |||||
return Constant::getAllOnesValue(ReturnType); | |||||
LLVM_FALLTHROUGH; | |||||
case Intrinsic::sadd_sat: | |||||
// sat(X + undef) -> -1 | |||||
// sat(undef + X) -> -1 | |||||
// For unsigned: Assume undef is MAX, thus we saturate to MAX (-1). | |||||
// For signed: Assume undef is ~X, in which case X + ~X = -1. | |||||
if (match(Op0, m_Undef()) || match(Op1, m_Undef())) | |||||
return Constant::getAllOnesValue(ReturnType); | |||||
// X + 0 -> X | |||||
if (match(Op1, m_Zero())) | |||||
return Op0; | |||||
// 0 + X -> X | |||||
if (match(Op0, m_Zero())) | |||||
return Op1; | |||||
break; | |||||
case Intrinsic::usub_sat: | |||||
// sat(0 - X) -> 0, sat(X - MAX) -> 0 | |||||
if (match(Op0, m_Zero()) || match(Op1, m_AllOnes())) | |||||
return Constant::getNullValue(ReturnType); | |||||
LLVM_FALLTHROUGH; | |||||
case Intrinsic::ssub_sat: | |||||
// X - X -> 0, X - undef -> 0, undef - X -> 0 | |||||
if (Op0 == Op1 || match(Op0, m_Undef()) || match(Op1, m_Undef())) | |||||
return Constant::getNullValue(ReturnType); | |||||
// X - 0 -> X | |||||
if (match(Op1, m_Zero())) | |||||
return Op0; | |||||
break; | |||||
case Intrinsic::load_relative: | case Intrinsic::load_relative: | ||||
if (auto *C0 = dyn_cast<Constant>(Op0)) | if (auto *C0 = dyn_cast<Constant>(Op0)) | ||||
if (auto *C1 = dyn_cast<Constant>(Op1)) | if (auto *C1 = dyn_cast<Constant>(Op1)) | ||||
return SimplifyRelativeLoad(C0, C1, Q.DL); | return SimplifyRelativeLoad(C0, C1, Q.DL); | ||||
break; | break; | ||||
case Intrinsic::powi: | case Intrinsic::powi: | ||||
if (auto *Power = dyn_cast<ConstantInt>(Op1)) { | if (auto *Power = dyn_cast<ConstantInt>(Op1)) { | ||||
// powi(x, 0) -> 1.0 | // powi(x, 0) -> 1.0 | ||||
▲ Show 20 Lines • Show All 434 Lines • Show Last 20 Lines |