[llvm] [IR][REVEC] Define llvm.vector.repeat intrinsic (PR #208212)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 06:15:09 PDT 2026


================
@@ -525,3 +525,20 @@ TEST_F(SelectionDAGNodeConstructionTest, ExpandPartialReduceSUMLA) {
   EXPECT_EQ(NumSignExtends, 1u);
   EXPECT_EQ(NumZeroExtends, 1u);
 }
+
+TEST_F(SelectionDAGNodeConstructionTest, VectorRepeat) {
+  SDLoc DL;
+  SDValue V1 = DAG->getCopyFromReg(DAG->getEntryNode(), DL,
+                                   Register::index2VirtReg(1), MVT::v1i32);
+  SDValue NXV1 = DAG->getNode(ISD::VECTOR_REPEAT, DL, MVT::nxv1i32, V1);
+
+  ASSERT_EQ(NXV1.getOpcode(), ISD::SPLAT_VECTOR);
+  ASSERT_EQ(NXV1.getOperand(0).getOpcode(), ISD::EXTRACT_VECTOR_ELT);
+  EXPECT_EQ(NXV1.getOperand(0).getOperand(0), V1);
+  EXPECT_TRUE(isNullConstant(NXV1.getOperand(0).getOperand(1)));
+
+  SDValue V2 = DAG->getCopyFromReg(DAG->getEntryNode(), DL,
+                                   Register::index2VirtReg(2), MVT::v2i32);
+  SDValue NXV2 = DAG->getNode(ISD::VECTOR_REPEAT, DL, MVT::nxv2i32, V2);
+  EXPECT_EQ(NXV2.getOpcode(), ISD::VECTOR_REPEAT);
----------------
gbossu wrote:

The point of this test is to check that `DAG->getNode(ISD::VECTOR_REPEAT)` sometimes generates a splat, and sometimes generates an actual `ISD::VECTOR_REPEAT`. I felt it was important to test given that this impacts ISel for backends down the line (i.e. they don't need to handle repeats to nxv1 types). I can get rid of it altogether if you feel it's superfluous.

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


More information about the llvm-commits mailing list