[DAGCombiner] convert StoreSource if-chain to switch; NFC

The "isa" checks were less constrained because they allow
target constants, but the later matching code would bail
out on those anyway, so this should be slightly more
efficient.
This commit is contained in:
Sanjay Patel 2020-08-17 13:27:27 -04:00
parent a79e604462
commit 27708db3e3
1 changed files with 9 additions and 5 deletions

View File

@ -641,14 +641,18 @@ namespace {
// Classify the origin of a stored value.
enum class StoreSource { Unknown, Constant, Extract, Load };
StoreSource getStoreSource(SDValue StoreVal) {
if (isa<ConstantSDNode>(StoreVal) || isa<ConstantFPSDNode>(StoreVal))
switch (StoreVal.getOpcode()) {
case ISD::Constant:
case ISD::ConstantFP:
return StoreSource::Constant;
if (StoreVal.getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
StoreVal.getOpcode() == ISD::EXTRACT_SUBVECTOR)
case ISD::EXTRACT_VECTOR_ELT:
case ISD::EXTRACT_SUBVECTOR:
return StoreSource::Extract;
if (isa<LoadSDNode>(StoreVal))
case ISD::LOAD:
return StoreSource::Load;
return StoreSource::Unknown;
default:
return StoreSource::Unknown;
}
}
/// This is a helper function for visitMUL to check the profitability