[llvm] [RISCV] Handle .vx/.vi pseudos in hasAllNBitUsers (PR #67419)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 09:49:38 PDT 2023


================
@@ -2752,6 +2752,175 @@ bool RISCVDAGToDAGISel::selectSHXADD_UWOp(SDValue N, unsigned ShAmt,
   return false;
 }
 
+static bool vectorPseudoHasAllNBitUsers(SDNode *User, unsigned UserOpNo,
+                                        unsigned Bits,
+                                        const TargetInstrInfo *TII) {
+  const RISCVVPseudosTable::PseudoInfo *PseudoInfo =
+      RISCVVPseudosTable::getPseudoInfo(User->getMachineOpcode());
+
+  if (!PseudoInfo)
+    return false;
+
+  const MCInstrDesc &MCID = TII->get(User->getMachineOpcode());
+  const uint64_t TSFlags = MCID.TSFlags;
+  if (!RISCVII::hasSEWOp(TSFlags))
+    return false;
+  assert(RISCVII::hasVLOp(TSFlags));
+
+  bool HasGlueOp = User->getGluedNode() != nullptr;
+  unsigned ChainOpIdx = User->getNumOperands() - HasGlueOp - 1;
+  bool HasChainOp = User->getOperand(ChainOpIdx).getValueType() == MVT::Other;
+  bool HasVecPolicyOp = RISCVII::hasVecPolicyOp(TSFlags);
+  unsigned VLIdx =
+      User->getNumOperands() - HasVecPolicyOp - HasChainOp - HasGlueOp - 2;
+  const unsigned Log2SEW = User->getConstantOperandVal(VLIdx + 1);
+
+  // TODO: The Largest VL 65,536 occurs for LMUL=8 and SEW=8 with
+  // VLEN=65,536. We could check if Bits < 16 here.
+  if (UserOpNo == VLIdx)
----------------
topperc wrote:

If the AVL was something large like 0x80000000 and we say that the instruction only demands the lower 17 bits, we could turn the AVL into 0. That seems incorrect.

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


More information about the llvm-commits mailing list