[Hexagon] Implement TLI::isExtractSubvectorCheap hook
authorKrzysztof Parzyszek <kparzysz@quicinc.com>
Wed, 12 Oct 2022 18:35:59 +0000 (11:35 -0700)
committerKrzysztof Parzyszek <kparzysz@quicinc.com>
Wed, 12 Oct 2022 19:48:56 +0000 (12:48 -0700)
llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
llvm/lib/Target/Hexagon/HexagonISelLowering.h

index e29fda8..da86291 100644 (file)
@@ -2141,6 +2141,20 @@ bool HexagonTargetLowering::shouldExpandBuildVectorWithShuffles(EVT VT,
   return false;
 }
 
+bool HexagonTargetLowering::isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
+      unsigned Index) const {
+  assert(ResVT.getVectorElementType() == SrcVT.getVectorElementType());
+  if (!ResVT.isSimple() || !SrcVT.isSimple())
+    return false;
+
+  MVT ResTy = ResVT.getSimpleVT(), SrcTy = SrcVT.getSimpleVT();
+  if (ResTy.getVectorElementType() != MVT::i1)
+    return true;
+
+  // Non-HVX bool vectors are relatively cheap.
+  return SrcTy.getVectorNumElements() <= 8;
+}
+
 bool HexagonTargetLowering::isShuffleMaskLegal(ArrayRef<int> Mask,
                                                EVT VT) const {
   return true;
index fcd9d28..07c6cea 100644 (file)
@@ -158,6 +158,8 @@ public:
   // Should we expand the build vector with shuffles?
   bool shouldExpandBuildVectorWithShuffles(EVT VT,
       unsigned DefinedValues) const override;
+  bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
+      unsigned Index) const override;
 
   bool isShuffleMaskLegal(ArrayRef<int> Mask, EVT VT) const override;
   TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT)