[llvm] [RISCV] Use `experimental-p` extension for zero-extended narrow unsigned types (PR #213260)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 07:16:27 PDT 2026


================
@@ -557,6 +559,113 @@ void RISCVDAGToDAGISel::selectXSfmmVSET(SDNode *Node) {
   }
 }
 
+bool RISCVDAGToDAGISel::tryPExtNarrowUnsigned(SDNode *Node) {
+  using namespace SDPatternMatch;
+
+  EVT VT = Node->getValueType(0);
+  SDLoc DL(Node);
+
+  APInt ConstMask;
+
+  if (sd_match(Node,
+               m_And(m_Add(m_Value(), m_Value()), m_ConstInt(ConstMask)))) {
+    uint64_t ConstMaskVal = ConstMask.getZExtValue();
+    if (ConstMaskVal != 255 && ConstMaskVal != 65535)
+      return false;
+
+    uint64_t PAddOpcode = (ConstMaskVal == 255) ? RISCV::PADD_B : RISCV::PADD_H;
+    uint64_t MinZeroBits = (ConstMaskVal == 255) ? 24 : 16;
----------------
topperc wrote:

This is incorrect for RV64.

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


More information about the llvm-commits mailing list