Widening cleanup
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58796 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index d03c4a2..f9d1ddc 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -100,9 +100,9 @@
/// processed to the result.
std::map<SDValue, SDValue> ScalarizedNodes;
- /// WidenNodes - For nodes that need to be widen from one vector type to
- /// another, this contains the mapping of ones we have already widen. This
- /// allows us to avoid widening more than once.
+ /// WidenNodes - For nodes that need to be widened from one vector type to
+ /// another, this contains the mapping of those that we have already widen.
+ /// This allows us to avoid widening more than once.
std::map<SDValue, SDValue> WidenNodes;
void AddLegalizedOperand(SDValue From, SDValue To) {
@@ -117,7 +117,7 @@
// If someone requests legalization of the new node, return itself.
LegalizedNodes.insert(std::make_pair(To, To));
}
- void AddWidenOperand(SDValue From, SDValue To) {
+ void AddWidenedOperand(SDValue From, SDValue To) {
bool isNew = WidenNodes.insert(std::make_pair(From, To)).second;
assert(isNew && "Got into the map somehow?");
// If someone requests legalization of the new node, return itself.
@@ -180,13 +180,12 @@
/// types.
void ExpandOp(SDValue O, SDValue &Lo, SDValue &Hi);
- /// WidenVectorOp - Widen a vector operation in order to do the computation
- /// in a wider type given to a wider type given by WidenVT (e.g., v3i32 to
- /// v4i32). The produced value will have the correct value for the existing
- /// elements but no guarantee is made about the new elements at the end of
- /// the vector: it may be zero, sign-extended, or garbage. This is useful
- /// when we have instruction operating on an illegal vector type and we want
- /// to widen it to do the computation on a legal wider vector type.
+ /// WidenVectorOp - Widen a vector operation to a wider type given by WidenVT
+ /// (e.g., v3i32 to v4i32). The produced value will have the correct value
+ /// for the existing elements but no guarantee is made about the new elements
+ /// at the end of the vector: it may be zero, ones, or garbage. This is useful
+ /// when we have an instruction operating on an illegal vector type and we
+ /// want to widen it to do the computation on a legal wider vector type.
SDValue WidenVectorOp(SDValue Op, MVT WidenVT);
/// SplitVectorOp - Given an operand of vector type, break it down into
@@ -198,7 +197,7 @@
/// scalar (e.g. f32) value.
SDValue ScalarizeVectorOp(SDValue O);
- /// Useful 16 element vector used to pass operands for widening
+ /// Useful 16 element vector type that is used to pass operands for widening.
typedef SmallVector<SDValue, 16> SDValueVector;
/// LoadWidenVectorOp - Load a vector for a wider type. Returns true if
@@ -7583,8 +7582,7 @@
// the legal type, the resulting code will be more efficient. If this is not
// the case, the resulting code will preform badly as we end up generating
// code to pack/unpack the results. It is the function that calls widen
- // that is responsible for seeing this doesn't happen. For some cases, we
- // have decided that it is not worth widening so we just split the operation.
+ // that is responsible for seeing this doesn't happen.
switch (Node->getOpcode()) {
default:
#ifndef NDEBUG
@@ -8017,7 +8015,7 @@
if (Result != Op)
Result = LegalizeOp(Result);
- AddWidenOperand(Op, Result);
+ AddWidenedOperand(Op, Result);
return Result;
}
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index 7f33b87..172a46e 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -80,13 +80,14 @@
return Legal;
case TargetLowering::Promote:
// Promote can mean
- // 1) On integers, it means to promote type (e.g., i8 to i32)
- // 2) For vectors, it means try to widen (e.g., v3i32 to v4i32)
+ // 1) On integers, use the promote integer type (e.g., i8 to i32)
+ // 2) For vectors, use the widen vector type returned by the target
+ // (e.g., v3i32 to v4i32). If the type is the same as the original
+ // type, than expand the vector instead.
if (!VT.isVector()) {
return PromoteInteger;
- }
- else {
- // TODO: move widen code to LegalizeType
+ } else {
+ // TODO: move widen code to LegalizeType.
if (VT.getVectorNumElements() == 1) {
return ScalarizeVector;
} else {
diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 9410271..ed80b40 100644
--- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -645,7 +645,7 @@
/// getWidenVectorType: given a vector type, returns the type to widen to
/// (e.g., v7i8 to v8i8). If the vector type is legal, it returns itself.
/// If there is no vector type that we want to widen to, returns MVT::Other
-/// When and were to widen is target dependent based on the cost of
+/// When and where to widen is target dependent based on the cost of
/// scalarizing vs using the wider vector type.
MVT TargetLowering::getWidenVectorType(MVT VT) {
assert(VT.isVector());