[llvm] 3927b9a - [VectorCombine] Add tests for unspeculatable VP binops. NFC
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 11:23:13 PDT 2023
Author: Luke Lau
Date: 2023-10-18T14:23:02-04:00
New Revision: 3927b9ab11541b23c29e5ab2bdd8976aed2ce8b9
URL: https://github.com/llvm/llvm-project/commit/3927b9ab11541b23c29e5ab2bdd8976aed2ce8b9
DIFF: https://github.com/llvm/llvm-project/commit/3927b9ab11541b23c29e5ab2bdd8976aed2ce8b9.diff
LOG: [VectorCombine] Add tests for unspeculatable VP binops. NFC
The current test cases to guard against speculative execution can actually be
safely speculated because the denominator is known to be not 0 or -1, and
isSafeToSpeculativelyExecuteWithOpcode will account for this. This adds some
more test cases and rejigs some existing ones to use an unknown variable
instead.
Added:
Modified:
llvm/test/Transforms/VectorCombine/RISCV/vpintrin-scalarization.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/VectorCombine/RISCV/vpintrin-scalarization.ll b/llvm/test/Transforms/VectorCombine/RISCV/vpintrin-scalarization.ll
index ea1831210b0630e..da183a6b14bc687 100644
--- a/llvm/test/Transforms/VectorCombine/RISCV/vpintrin-scalarization.ll
+++ b/llvm/test/Transforms/VectorCombine/RISCV/vpintrin-scalarization.ll
@@ -199,6 +199,27 @@ define <vscale x 1 x i64> @sdiv_nxv1i64_anymask(<vscale x 1 x i64> %x, i64 %y, <
ret <vscale x 1 x i64> %4
}
+define <vscale x 1 x i64> @sdiv_nxv1i64_unspeculatable(i64 %x, i64 %y, i32 zeroext %evl) {
+; ALL-LABEL: @sdiv_nxv1i64_unspeculatable(
+; ALL-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; ALL-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 [[EVL:%.*]])
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 %evl)
+ ret <vscale x 1 x i64> %res
+}
+
define <vscale x 1 x i64> @udiv_nxv1i64_allonesmask(<vscale x 1 x i64> %x, i64 %y, i32 zeroext %evl) {
; ALL-LABEL: @udiv_nxv1i64_allonesmask(
; ALL-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
@@ -233,6 +254,27 @@ define <vscale x 1 x i64> @udiv_nxv1i64_anymask(<vscale x 1 x i64> %x, i64 %y, <
ret <vscale x 1 x i64> %4
}
+define <vscale x 1 x i64> @udiv_nxv1i64_unspeculatable(i64 %x, i64 %y, i32 zeroext %evl) {
+; ALL-LABEL: @udiv_nxv1i64_unspeculatable(
+; ALL-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; ALL-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 [[EVL:%.*]])
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 %evl)
+ ret <vscale x 1 x i64> %res
+}
+
define <vscale x 1 x i64> @srem_nxv1i64_allonesmask(<vscale x 1 x i64> %x, i64 %y, i32 zeroext %evl) {
; ALL-LABEL: @srem_nxv1i64_allonesmask(
; ALL-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
@@ -267,6 +309,27 @@ define <vscale x 1 x i64> @srem_nxv1i64_anymask(<vscale x 1 x i64> %x, i64 %y, <
ret <vscale x 1 x i64> %4
}
+define <vscale x 1 x i64> @srem_nxv1i64_unspeculatable(i64 %x, i64 %y, i32 zeroext %evl) {
+; ALL-LABEL: @srem_nxv1i64_unspeculatable(
+; ALL-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; ALL-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 [[EVL:%.*]])
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 %evl)
+ ret <vscale x 1 x i64> %res
+}
+
define <vscale x 1 x i64> @urem_nxv1i64_allonesmask(<vscale x 1 x i64> %x, i64 %y, i32 zeroext %evl) {
; ALL-LABEL: @urem_nxv1i64_allonesmask(
; ALL-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
@@ -301,176 +364,201 @@ define <vscale x 1 x i64> @urem_nxv1i64_anymask(<vscale x 1 x i64> %x, i64 %y, <
ret <vscale x 1 x i64> %4
}
-define <vscale x 1 x i64> @sdiv_nxv1i64_allonesmask_knownvl(<vscale x 1 x i64> %x, i64 %y) {
+define <vscale x 1 x i64> @urem_nxv1i64_unspeculatable(i64 %x, i64 %y, i32 zeroext %evl) {
+; ALL-LABEL: @urem_nxv1i64_unspeculatable(
+; ALL-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; ALL-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 [[EVL:%.*]])
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 %evl)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @sdiv_nxv1i64_allonesmask_knownvl(i64 %x, i64 %y) {
; VEC-COMBINE-LABEL: @sdiv_nxv1i64_allonesmask_knownvl(
-; VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP1:%.*]] = sdiv i64 [[Y:%.*]], 42
+; VEC-COMBINE-NEXT: [[TMP1:%.*]] = sdiv i64 [[X:%.*]], [[X]]
; VEC-COMBINE-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[TMP1]], i64 0
-; VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP2]], <vscale x 1 x i1> [[MASK]], i32 4)
-; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP3]]
+; VEC-COMBINE-NEXT: [[RES:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
;
; NO-VEC-COMBINE-LABEL: @sdiv_nxv1i64_allonesmask_knownvl(
-; NO-VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; NO-VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %splat = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
- %mask = shufflevector <vscale x 1 x i1> %splat, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
-}
-
-define <vscale x 1 x i64> @sdiv_nxv1i64_anymask_knownvl(<vscale x 1 x i64> %x, i64 %y, <vscale x 1 x i1> %mask) {
+; NO-VEC-COMBINE-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; NO-VEC-COMBINE-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; NO-VEC-COMBINE-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 4)
+; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @sdiv_nxv1i64_anymask_knownvl(i64 %x, i64 %y, <vscale x 1 x i1> %mask) {
; ALL-LABEL: @sdiv_nxv1i64_anymask_knownvl(
-; ALL-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; ALL-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; ALL-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK:%.*]], i32 4)
-; ALL-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; ALL-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
-}
-
-define <vscale x 1 x i64> @udiv_nxv1i64_allonesmask_knownvl(<vscale x 1 x i64> %x, i64 %y) {
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK:%.*]], i32 4)
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.sdiv.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @udiv_nxv1i64_allonesmask_knownvl(i64 %x, i64 %y) {
; VEC-COMBINE-LABEL: @udiv_nxv1i64_allonesmask_knownvl(
-; VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP1:%.*]] = udiv i64 [[Y:%.*]], 42
+; VEC-COMBINE-NEXT: [[TMP1:%.*]] = udiv i64 [[X:%.*]], [[X]]
; VEC-COMBINE-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[TMP1]], i64 0
-; VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP2]], <vscale x 1 x i1> [[MASK]], i32 4)
-; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP3]]
+; VEC-COMBINE-NEXT: [[RES:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
;
; NO-VEC-COMBINE-LABEL: @udiv_nxv1i64_allonesmask_knownvl(
-; NO-VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; NO-VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %splat = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
- %mask = shufflevector <vscale x 1 x i1> %splat, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
-}
-
-define <vscale x 1 x i64> @udiv_nxv1i64_anymask_knownvl(<vscale x 1 x i64> %x, i64 %y, <vscale x 1 x i1> %mask) {
+; NO-VEC-COMBINE-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; NO-VEC-COMBINE-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; NO-VEC-COMBINE-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 4)
+; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @udiv_nxv1i64_anymask_knownvl(i64 %x, i64 %y, <vscale x 1 x i1> %mask) {
; ALL-LABEL: @udiv_nxv1i64_anymask_knownvl(
-; ALL-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; ALL-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; ALL-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK:%.*]], i32 4)
-; ALL-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; ALL-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
-}
-
-define <vscale x 1 x i64> @srem_nxv1i64_allonesmask_knownvl(<vscale x 1 x i64> %x, i64 %y) {
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK:%.*]], i32 4)
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.udiv.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @srem_nxv1i64_allonesmask_knownvl(i64 %x, i64 %y) {
; VEC-COMBINE-LABEL: @srem_nxv1i64_allonesmask_knownvl(
-; VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP1:%.*]] = srem i64 [[Y:%.*]], 42
+; VEC-COMBINE-NEXT: [[TMP1:%.*]] = srem i64 [[X:%.*]], [[X]]
; VEC-COMBINE-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[TMP1]], i64 0
-; VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP2]], <vscale x 1 x i1> [[MASK]], i32 4)
-; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP3]]
+; VEC-COMBINE-NEXT: [[RES:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
;
; NO-VEC-COMBINE-LABEL: @srem_nxv1i64_allonesmask_knownvl(
-; NO-VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; NO-VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %splat = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
- %mask = shufflevector <vscale x 1 x i1> %splat, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
-}
-
-define <vscale x 1 x i64> @srem_nxv1i64_anymask_knownvl(<vscale x 1 x i64> %x, i64 %y, <vscale x 1 x i1> %mask) {
+; NO-VEC-COMBINE-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; NO-VEC-COMBINE-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; NO-VEC-COMBINE-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 4)
+; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @srem_nxv1i64_anymask_knownvl(i64 %x, i64 %y, <vscale x 1 x i1> %mask) {
; ALL-LABEL: @srem_nxv1i64_anymask_knownvl(
-; ALL-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; ALL-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; ALL-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK:%.*]], i32 4)
-; ALL-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; ALL-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
-}
-
-define <vscale x 1 x i64> @urem_nxv1i64_allonesmask_knownvl(<vscale x 1 x i64> %x, i64 %y) {
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK:%.*]], i32 4)
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.srem.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @urem_nxv1i64_allonesmask_knownvl(i64 %x, i64 %y) {
; VEC-COMBINE-LABEL: @urem_nxv1i64_allonesmask_knownvl(
-; VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP1:%.*]] = urem i64 [[Y:%.*]], 42
+; VEC-COMBINE-NEXT: [[TMP1:%.*]] = urem i64 [[X:%.*]], [[X]]
; VEC-COMBINE-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[TMP1]], i64 0
-; VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP2]], <vscale x 1 x i1> [[MASK]], i32 4)
-; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP3]]
+; VEC-COMBINE-NEXT: [[RES:%.*]] = shufflevector <vscale x 1 x i64> [[DOTSPLATINSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
;
; NO-VEC-COMBINE-LABEL: @urem_nxv1i64_allonesmask_knownvl(
-; NO-VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
-; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[SPLAT]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; NO-VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; NO-VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %splat = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
- %mask = shufflevector <vscale x 1 x i1> %splat, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
-}
-
-define <vscale x 1 x i64> @urem_nxv1i64_anymask_knownvl(<vscale x 1 x i64> %x, i64 %y, <vscale x 1 x i1> %mask) {
+; NO-VEC-COMBINE-NEXT: [[MASK_HEAD:%.*]] = insertelement <vscale x 1 x i1> poison, i1 true, i32 0
+; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 1 x i1> [[MASK_HEAD]], <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; NO-VEC-COMBINE-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; NO-VEC-COMBINE-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; NO-VEC-COMBINE-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK]], i32 4)
+; NO-VEC-COMBINE-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %mask.head = insertelement <vscale x 1 x i1> poison, i1 -1, i32 0
+ %mask = shufflevector <vscale x 1 x i1> %mask.head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 1 x i64> @urem_nxv1i64_anymask_knownvl(i64 %x, i64 %y, <vscale x 1 x i1> %mask) {
; ALL-LABEL: @urem_nxv1i64_anymask_knownvl(
-; ALL-NEXT: [[TMP1:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[Y:%.*]], i64 0
-; ALL-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 1 x i64> [[TMP1]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
-; ALL-NEXT: [[TMP3:%.*]] = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> [[TMP2]], <vscale x 1 x i64> shufflevector (<vscale x 1 x i64> insertelement (<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> [[MASK:%.*]], i32 4)
-; ALL-NEXT: [[TMP4:%.*]] = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> [[X:%.*]], <vscale x 1 x i64> [[TMP3]], <vscale x 1 x i1> [[MASK]], i32 4)
-; ALL-NEXT: ret <vscale x 1 x i64> [[TMP4]]
-;
- %1 = insertelement <vscale x 1 x i64> poison, i64 %y, i64 0
- %2 = shufflevector <vscale x 1 x i64> %1, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
- %3 = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> %2, <vscale x 1 x i64> shufflevector(<vscale x 1 x i64> insertelement(<vscale x 1 x i64> poison, i64 42, i32 0), <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i1> %mask, i32 4)
- %4 = call <vscale x 1 x i64> @llvm.vp.mul.nxv1i64(<vscale x 1 x i64> %x, <vscale x 1 x i64> %3, <vscale x 1 x i1> %mask, i32 4)
- ret <vscale x 1 x i64> %4
+; ALL-NEXT: [[X_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X:%.*]], i64 0
+; ALL-NEXT: [[X_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[X_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[Y_HEAD:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[X]], i64 0
+; ALL-NEXT: [[Y_SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[Y_HEAD]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; ALL-NEXT: [[RES:%.*]] = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> [[X_SPLAT]], <vscale x 1 x i64> [[Y_SPLAT]], <vscale x 1 x i1> [[MASK:%.*]], i32 4)
+; ALL-NEXT: ret <vscale x 1 x i64> [[RES]]
+;
+ %x.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %x.splat = shufflevector <vscale x 1 x i64> %x.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %y.head = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
+ %y.splat = shufflevector <vscale x 1 x i64> %y.head, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %res = call <vscale x 1 x i64> @llvm.vp.urem.nxv1i64(<vscale x 1 x i64> %x.splat, <vscale x 1 x i64> %y.splat, <vscale x 1 x i1> %mask, i32 4)
+ ret <vscale x 1 x i64> %res
}
define <vscale x 1 x i64> @ashr_nxv1i64_allonesmask(<vscale x 1 x i64> %x, i64 %y, i32 zeroext %evl) {
More information about the llvm-commits
mailing list