[Hexagon] Prefer to widen HVX vectors instead of promoting

llvm-svn: 321002
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 6ae5270..6387ac2e 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -2323,6 +2323,18 @@
   return true;
 }
 
+TargetLoweringBase::LegalizeTypeAction
+HexagonTargetLowering::getPreferredVectorAction(EVT VT) const {
+  if (Subtarget.useHVXOps()) {
+    // If the size of VT is at least half of the vector length,
+    // widen the vector. Note: the threshold was not selected in
+    // any scientific way.
+    if (VT.getSizeInBits() >= Subtarget.getVectorLength()*8/2)
+      return TargetLoweringBase::TypeWidenVector;
+  }
+  return TargetLowering::getPreferredVectorAction(VT);
+}
+
 // Lower a vector shuffle (V1, V2, V3).  V1 and V2 are the two vectors
 // to select data from, V3 is the permutation.
 SDValue