Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | for (const SDValue &Op : N->op_values()) { | ||||
if (!isa<ConstantFPSDNode>(Op)) | if (!isa<ConstantFPSDNode>(Op)) | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool ISD::isVectorShrinkable(const SDNode *N, unsigned NewEltSize, | bool ISD::isVectorShrinkable(const SDNode *N, unsigned NewEltSize, | ||||
bool Signed) { | bool Signed) { | ||||
if (N->getOpcode() != ISD::BUILD_VECTOR) | assert(N->getValueType(0).isVector() && "Expected a vector!"); | ||||
paulwalker-arm: I'm probably just being paranoid but with this code now sitting after the call to… | |||||
return false; | |||||
unsigned EltSize = N->getValueType(0).getScalarSizeInBits(); | unsigned EltSize = N->getValueType(0).getScalarSizeInBits(); | ||||
if (EltSize <= NewEltSize) | if (EltSize <= NewEltSize) | ||||
return false; | return false; | ||||
if (N->getOpcode() == ISD::ZERO_EXTEND) { | |||||
return (N->getOperand(0).getValueType().getScalarSizeInBits() <= | |||||
Not Done ReplyInline ActionsIt's not sufficient to only consider the result type of the extend. For example, take isVectorShrinkable(zext_to_i64(i48_node, 32, false) With the current implementation you'll return true but: zext_to_i64(trunc_to_i32(i48_node)) != zext_to_i64(i48_node) For the sext & zext cases I think you also need N's operand to be <= NewEltSize paulwalker-arm: It's not sufficient to only consider the result type of the extend. For example, take
```… | |||||
NewEltSize) && | |||||
!Signed; | |||||
} | |||||
if (N->getOpcode() == ISD::SIGN_EXTEND) { | |||||
return (N->getOperand(0).getValueType().getScalarSizeInBits() <= | |||||
NewEltSize) && | |||||
Signed; | |||||
} | |||||
if (N->getOpcode() != ISD::BUILD_VECTOR) | |||||
return false; | |||||
for (const SDValue &Op : N->op_values()) { | for (const SDValue &Op : N->op_values()) { | ||||
if (Op.isUndef()) | if (Op.isUndef()) | ||||
continue; | continue; | ||||
if (!isa<ConstantSDNode>(Op)) | if (!isa<ConstantSDNode>(Op)) | ||||
return false; | return false; | ||||
APInt C = cast<ConstantSDNode>(Op)->getAPIntValue().trunc(EltSize); | APInt C = cast<ConstantSDNode>(Op)->getAPIntValue().trunc(EltSize); | ||||
if (Signed && C.trunc(NewEltSize).sext(EltSize) != C) | if (Signed && C.trunc(NewEltSize).sext(EltSize) != C) | ||||
▲ Show 20 Lines • Show All 11,691 Lines • Show Last 20 Lines |
I'm probably just being paranoid but with this code now sitting after the call to getScalarSizeInBits() can you add something like assert(N->getValueType(0).isVector() && "Expected a vector!"); here? just in case.