Skip to content

Commit 2b96e3f

Browse files
fixup! [InstCombine][RISCV] Convert VPIntrinsics with splat operands to splats of the scalar operation
Add zvfh and VEC-COMBINE-64/32
1 parent ca48343 commit 2b96e3f

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

llvm/test/Transforms/VectorCombine/RISCV/vpintrin-scalarization.ll

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt -S -mtriple=riscv64 -mattr=+v,+m %s -passes=vector-combine | FileCheck %s --check-prefixes=ALL,VEC-COMBINE
3-
; RUN: opt -S -mtriple=riscv64 -mattr=+v,+m %s | FileCheck %s --check-prefixes=ALL,NO-VEC-COMBINE
4-
; RUN: opt -S -mtriple=riscv32 -mattr=+v,+m %s -passes=vector-combine | FileCheck %s --check-prefixes=ALL,VEC-COMBINE
5-
; RUN: opt -S -mtriple=riscv32 -mattr=+v,+m %s | FileCheck %s --check-prefixes=ALL,NO-VEC-COMBINE
2+
; RUN: opt -S -mtriple=riscv64 -mattr=+v,+m,+zvfh %s -passes=vector-combine | FileCheck %s --check-prefixes=ALL,VEC-COMBINE,VEC-COMBINE-64
3+
; RUN: opt -S -mtriple=riscv64 -mattr=+v,+m,+zvfh %s | FileCheck %s --check-prefixes=ALL,NO-VEC-COMBINE
4+
; RUN: opt -S -mtriple=riscv32 -mattr=+v,+m,+zvfh %s -passes=vector-combine | FileCheck %s --check-prefixes=ALL,VEC-COMBINE,VEC-COMBINE-32
5+
; RUN: opt -S -mtriple=riscv32 -mattr=+v,+m,+zvfh %s | FileCheck %s --check-prefixes=ALL,NO-VEC-COMBINE
66

77
declare <vscale x 1 x i64> @llvm.vp.add.nxv1i64(<vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i1>, i32)
88
declare <vscale x 1 x i64> @llvm.vp.sub.nxv1i64(<vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i1>, i32)
@@ -1301,14 +1301,23 @@ define <vscale x 8 x i8> @add_nxv8i8_anymask(<vscale x 8 x i8> %x, i8 %y, <vscal
13011301
}
13021302

13031303
define <vscale x 8 x half> @fadd_nxv1f16_allonesmask(<vscale x 8 x half> %x, half %y, i32 zeroext %evl) {
1304-
; ALL-LABEL: @fadd_nxv1f16_allonesmask(
1305-
; ALL-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 8 x i1> poison, i1 true, i32 0
1306-
; ALL-NEXT: [[MASK:%.*]] = shufflevector <vscale x 8 x i1> [[SPLAT]], <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
1307-
; ALL-NEXT: [[TMP1:%.*]] = insertelement <vscale x 8 x half> poison, half [[Y:%.*]], i64 0
1308-
; ALL-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 8 x half> [[TMP1]], <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
1309-
; ALL-NEXT: [[TMP3:%.*]] = call <vscale x 8 x half> @llvm.vp.fadd.nxv8f16(<vscale x 8 x half> [[TMP2]], <vscale x 8 x half> shufflevector (<vscale x 8 x half> insertelement (<vscale x 8 x half> poison, half 0xH5140, i32 0), <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer), <vscale x 8 x i1> [[MASK]], i32 [[EVL:%.*]])
1310-
; ALL-NEXT: [[TMP4:%.*]] = call <vscale x 8 x half> @llvm.vp.fadd.nxv8f16(<vscale x 8 x half> [[X:%.*]], <vscale x 8 x half> [[TMP3]], <vscale x 8 x i1> [[MASK]], i32 [[EVL]])
1311-
; ALL-NEXT: ret <vscale x 8 x half> [[TMP4]]
1304+
; VEC-COMBINE-LABEL: @fadd_nxv1f16_allonesmask(
1305+
; VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 8 x i1> poison, i1 true, i32 0
1306+
; VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 8 x i1> [[SPLAT]], <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
1307+
; VEC-COMBINE-NEXT: [[TMP1:%.*]] = fadd half [[Y:%.*]], 0xH5140
1308+
; VEC-COMBINE-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 8 x half> poison, half [[TMP1]], i64 0
1309+
; VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 8 x half> [[DOTSPLATINSERT]], <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
1310+
; VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 8 x half> @llvm.vp.fadd.nxv8f16(<vscale x 8 x half> [[X:%.*]], <vscale x 8 x half> [[TMP2]], <vscale x 8 x i1> [[MASK]], i32 [[EVL:%.*]])
1311+
; VEC-COMBINE-NEXT: ret <vscale x 8 x half> [[TMP3]]
1312+
;
1313+
; NO-VEC-COMBINE-LABEL: @fadd_nxv1f16_allonesmask(
1314+
; NO-VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <vscale x 8 x i1> poison, i1 true, i32 0
1315+
; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <vscale x 8 x i1> [[SPLAT]], <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
1316+
; NO-VEC-COMBINE-NEXT: [[TMP1:%.*]] = insertelement <vscale x 8 x half> poison, half [[Y:%.*]], i64 0
1317+
; NO-VEC-COMBINE-NEXT: [[TMP2:%.*]] = shufflevector <vscale x 8 x half> [[TMP1]], <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer
1318+
; NO-VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <vscale x 8 x half> @llvm.vp.fadd.nxv8f16(<vscale x 8 x half> [[TMP2]], <vscale x 8 x half> shufflevector (<vscale x 8 x half> insertelement (<vscale x 8 x half> poison, half 0xH5140, i32 0), <vscale x 8 x half> poison, <vscale x 8 x i32> zeroinitializer), <vscale x 8 x i1> [[MASK]], i32 [[EVL:%.*]])
1319+
; NO-VEC-COMBINE-NEXT: [[TMP4:%.*]] = call <vscale x 8 x half> @llvm.vp.fadd.nxv8f16(<vscale x 8 x half> [[X:%.*]], <vscale x 8 x half> [[TMP3]], <vscale x 8 x i1> [[MASK]], i32 [[EVL]])
1320+
; NO-VEC-COMBINE-NEXT: ret <vscale x 8 x half> [[TMP4]]
13121321
;
13131322
%splat = insertelement <vscale x 8 x i1> poison, i1 -1, i32 0
13141323
%mask = shufflevector <vscale x 8 x i1> %splat, <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
@@ -1335,6 +1344,15 @@ define <vscale x 8 x half> @fadd_nxv8f16_anymask(<vscale x 8 x half> %x, half %y
13351344
}
13361345

13371346
define <1 x i64> @add_v1i64_allonesmask(<1 x i64> %x, i64 %y, i32 zeroext %evl) {
1347+
; VEC-COMBINE-64-LABEL: @add_v1i64_allonesmask(
1348+
; VEC-COMBINE-64-NEXT: [[SPLAT:%.*]] = insertelement <1 x i1> poison, i1 true, i32 0
1349+
; VEC-COMBINE-64-NEXT: [[MASK:%.*]] = shufflevector <1 x i1> [[SPLAT]], <1 x i1> poison, <1 x i32> zeroinitializer
1350+
; VEC-COMBINE-64-NEXT: [[TMP1:%.*]] = add i64 [[Y:%.*]], 42
1351+
; VEC-COMBINE-64-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <1 x i64> poison, i64 [[TMP1]], i64 0
1352+
; VEC-COMBINE-64-NEXT: [[TMP2:%.*]] = shufflevector <1 x i64> [[DOTSPLATINSERT]], <1 x i64> poison, <1 x i32> zeroinitializer
1353+
; VEC-COMBINE-64-NEXT: [[TMP3:%.*]] = call <1 x i64> @llvm.vp.mul.v1i64(<1 x i64> [[X:%.*]], <1 x i64> [[TMP2]], <1 x i1> [[MASK]], i32 [[EVL:%.*]])
1354+
; VEC-COMBINE-64-NEXT: ret <1 x i64> [[TMP3]]
1355+
;
13381356
; NO-VEC-COMBINE-LABEL: @add_v1i64_allonesmask(
13391357
; NO-VEC-COMBINE-NEXT: [[SPLAT:%.*]] = insertelement <1 x i1> poison, i1 true, i32 0
13401358
; NO-VEC-COMBINE-NEXT: [[MASK:%.*]] = shufflevector <1 x i1> [[SPLAT]], <1 x i1> poison, <1 x i32> zeroinitializer
@@ -1343,6 +1361,15 @@ define <1 x i64> @add_v1i64_allonesmask(<1 x i64> %x, i64 %y, i32 zeroext %evl)
13431361
; NO-VEC-COMBINE-NEXT: [[TMP3:%.*]] = call <1 x i64> @llvm.vp.add.v1i64(<1 x i64> [[TMP2]], <1 x i64> <i64 42>, <1 x i1> [[MASK]], i32 [[EVL:%.*]])
13441362
; NO-VEC-COMBINE-NEXT: [[TMP4:%.*]] = call <1 x i64> @llvm.vp.mul.v1i64(<1 x i64> [[X:%.*]], <1 x i64> [[TMP3]], <1 x i1> [[MASK]], i32 [[EVL]])
13451363
; NO-VEC-COMBINE-NEXT: ret <1 x i64> [[TMP4]]
1364+
;
1365+
; VEC-COMBINE-32-LABEL: @add_v1i64_allonesmask(
1366+
; VEC-COMBINE-32-NEXT: [[SPLAT:%.*]] = insertelement <1 x i1> poison, i1 true, i32 0
1367+
; VEC-COMBINE-32-NEXT: [[MASK:%.*]] = shufflevector <1 x i1> [[SPLAT]], <1 x i1> poison, <1 x i32> zeroinitializer
1368+
; VEC-COMBINE-32-NEXT: [[TMP1:%.*]] = insertelement <1 x i64> poison, i64 [[Y:%.*]], i64 0
1369+
; VEC-COMBINE-32-NEXT: [[TMP2:%.*]] = shufflevector <1 x i64> [[TMP1]], <1 x i64> poison, <1 x i32> zeroinitializer
1370+
; VEC-COMBINE-32-NEXT: [[TMP3:%.*]] = call <1 x i64> @llvm.vp.add.v1i64(<1 x i64> [[TMP2]], <1 x i64> <i64 42>, <1 x i1> [[MASK]], i32 [[EVL:%.*]])
1371+
; VEC-COMBINE-32-NEXT: [[TMP4:%.*]] = call <1 x i64> @llvm.vp.mul.v1i64(<1 x i64> [[X:%.*]], <1 x i64> [[TMP3]], <1 x i1> [[MASK]], i32 [[EVL]])
1372+
; VEC-COMBINE-32-NEXT: ret <1 x i64> [[TMP4]]
13461373
;
13471374
%splat = insertelement <1 x i1> poison, i1 -1, i32 0
13481375
%mask = shufflevector <1 x i1> %splat, <1 x i1> poison, <1 x i32> zeroinitializer

0 commit comments

Comments
 (0)