[llvm] 2ff9175 - [RISCV] Normalize gather/scatter addressing to UNSIGNED_SCALAR

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 15:00:42 PDT 2023


Author: Philip Reames
Date: 2023-09-15T14:56:33-07:00
New Revision: 2ff9175af73eb4df7bd2fda35591a95e0c6ba236

URL: https://github.com/llvm/llvm-project/commit/2ff9175af73eb4df7bd2fda35591a95e0c6ba236
DIFF: https://github.com/llvm/llvm-project/commit/2ff9175af73eb4df7bd2fda35591a95e0c6ba236.diff

LOG: [RISCV] Normalize gather/scatter addressing to UNSIGNED_SCALAR

If the index type is greater or equal to XLEN, then signed and unsigned
are the same.  Canonacalize towards unsigned to simplify upcoming transform.

Note: Reviewed as part of a stack of changes in PR# 66405.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 9911fe6ac83ee3a..10212c867fb3520 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -13505,19 +13505,20 @@ static bool legalizeScatterGatherIndexType(SDLoc DL, SDValue &Index,
     DAG.getMachineFunction().getSubtarget<RISCVSubtarget>().getXLenVT();
 
   const EVT IndexVT = Index.getValueType();
-  const bool IsIndexSigned = isIndexTypeSigned(IndexType);
 
   // RISC-V indexed loads only support the "unsigned unscaled" addressing
   // mode, so anything else must be manually legalized.
-  if (!IsIndexSigned || !IndexVT.getVectorElementType().bitsLT(XLenVT))
+  if (!isIndexTypeSigned(IndexType))
     return false;
 
-  // Any index legalization should first promote to XLenVT, so we don't lose
-  // bits when scaling. This may create an illegal index type so we let
-  // LLVM's legalization take care of the splitting.
-  // FIXME: LLVM can't split VP_GATHER or VP_SCATTER yet.
-  Index = DAG.getNode(ISD::SIGN_EXTEND, DL,
-                      IndexVT.changeVectorElementType(XLenVT), Index);
+  if (IndexVT.getVectorElementType().bitsLT(XLenVT)) {
+    // Any index legalization should first promote to XLenVT, so we don't lose
+    // bits when scaling. This may create an illegal index type so we let
+    // LLVM's legalization take care of the splitting.
+    // FIXME: LLVM can't split VP_GATHER or VP_SCATTER yet.
+    Index = DAG.getNode(ISD::SIGN_EXTEND, DL,
+                        IndexVT.changeVectorElementType(XLenVT), Index);
+  }
   IndexType = ISD::UNSIGNED_SCALED;
   return true;
 }


        


More information about the llvm-commits mailing list