[llvm] [RISCV] Combine a gather to a larger element type (PR #66694)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 15:28:42 PDT 2023


================
@@ -14020,6 +14066,33 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
         DAG.getVectorShuffle(VT, DL, Load, DAG.getUNDEF(VT), ShuffleMask);
       return DAG.getMergeValues({Shuffle, Load.getValue(1)}, DL);
     }
+
+    if (MGN->getExtensionType() == ISD::NON_EXTLOAD &&
+        matchIndexAsWiderOp(VT, Index, MGN->getMask(),
+                            MGN->getMemOperand()->getBaseAlign(), Subtarget)) {
+      SmallVector<SDValue> NewIndices;
+      for (unsigned i = 0; i < Index->getNumOperands(); i += 2)
+        NewIndices.push_back(Index.getOperand(i));
+      EVT IndexVT = Index.getValueType()
+        .getHalfNumVectorElementsVT(*DAG.getContext());
+      Index = DAG.getBuildVector(IndexVT, DL, NewIndices);
+
+      unsigned ElementSize = VT.getScalarStoreSize();
+      EVT WideScalarVT = MVT::getIntegerVT(ElementSize * 8 * 2);
+      EVT WideVT = VT.changeVectorElementType(WideScalarVT)
----------------
preames wrote:

What would you think of explicitly constructing an EVT from VT, and then using this idiom?  Alternatively, do you have something better to recommend?

https://github.com/llvm/llvm-project/pull/66694


More information about the llvm-commits mailing list