Skip to content

Commit f443765

Browse files
committed
[RISCV] Remove bfloat vectors from AllFloatVectors. NFC
This removes a bunch of unreachable isel patterns for floating point operations like fadd, fsub, fmul, etc. Add a new AllFloatAndBFloatVectors for the instructions that we do need both for like vrgather, vcompress, vmerge.
1 parent fc3a27f commit f443765

File tree

3 files changed

+90
-78
lines changed

3 files changed

+90
-78
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 74 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -345,49 +345,60 @@ defset list<VTypeInfo> AllVectors = {
345345
}
346346
}
347347

348-
defset list<VTypeInfo> AllFloatVectors = {
349-
defset list<VTypeInfo> NoGroupFloatVectors = {
350-
defset list<VTypeInfo> FractionalGroupFloatVectors = {
351-
def VF16MF4: VTypeInfo<vfloat16mf4_t, vbool64_t, 16, V_MF4, f16, FPR16>;
352-
def VF16MF2: VTypeInfo<vfloat16mf2_t, vbool32_t, 16, V_MF2, f16, FPR16>;
353-
def VF32MF2: VTypeInfo<vfloat32mf2_t, vbool64_t, 32, V_MF2, f32, FPR32>;
354-
def VBF16MF4: VTypeInfo<vbfloat16mf4_t, vbool64_t, 16, V_MF4, bf16, FPR16>;
355-
def VBF16MF2: VTypeInfo<vbfloat16mf2_t, vbool32_t, 16, V_MF2, bf16, FPR16>;
348+
defset list<VTypeInfo> AllFloatAndBFloatVectors = {
349+
defset list<VTypeInfo> AllFloatVectors = {
350+
defset list<VTypeInfo> NoGroupFloatVectors = {
351+
defset list<VTypeInfo> FractionalGroupFloatVectors = {
352+
def VF16MF4: VTypeInfo<vfloat16mf4_t, vbool64_t, 16, V_MF4, f16, FPR16>;
353+
def VF16MF2: VTypeInfo<vfloat16mf2_t, vbool32_t, 16, V_MF2, f16, FPR16>;
354+
def VF32MF2: VTypeInfo<vfloat32mf2_t, vbool64_t, 32, V_MF2, f32, FPR32>;
355+
}
356+
def VF16M1: VTypeInfo<vfloat16m1_t, vbool16_t, 16, V_M1, f16, FPR16>;
357+
def VF32M1: VTypeInfo<vfloat32m1_t, vbool32_t, 32, V_M1, f32, FPR32>;
358+
def VF64M1: VTypeInfo<vfloat64m1_t, vbool64_t, 64, V_M1, f64, FPR64>;
359+
}
360+
361+
defset list<GroupVTypeInfo> GroupFloatVectors = {
362+
def VF16M2: GroupVTypeInfo<vfloat16m2_t, vfloat16m1_t, vbool8_t, 16,
363+
V_M2, f16, FPR16>;
364+
def VF16M4: GroupVTypeInfo<vfloat16m4_t, vfloat16m1_t, vbool4_t, 16,
365+
V_M4, f16, FPR16>;
366+
def VF16M8: GroupVTypeInfo<vfloat16m8_t, vfloat16m1_t, vbool2_t, 16,
367+
V_M8, f16, FPR16>;
368+
369+
def VF32M2: GroupVTypeInfo<vfloat32m2_t, vfloat32m1_t, vbool16_t, 32,
370+
V_M2, f32, FPR32>;
371+
def VF32M4: GroupVTypeInfo<vfloat32m4_t, vfloat32m1_t, vbool8_t, 32,
372+
V_M4, f32, FPR32>;
373+
def VF32M8: GroupVTypeInfo<vfloat32m8_t, vfloat32m1_t, vbool4_t, 32,
374+
V_M8, f32, FPR32>;
375+
376+
def VF64M2: GroupVTypeInfo<vfloat64m2_t, vfloat64m1_t, vbool32_t, 64,
377+
V_M2, f64, FPR64>;
378+
def VF64M4: GroupVTypeInfo<vfloat64m4_t, vfloat64m1_t, vbool16_t, 64,
379+
V_M4, f64, FPR64>;
380+
def VF64M8: GroupVTypeInfo<vfloat64m8_t, vfloat64m1_t, vbool8_t, 64,
381+
V_M8, f64, FPR64>;
356382
}
357-
def VF16M1: VTypeInfo<vfloat16m1_t, vbool16_t, 16, V_M1, f16, FPR16>;
358-
def VF32M1: VTypeInfo<vfloat32m1_t, vbool32_t, 32, V_M1, f32, FPR32>;
359-
def VF64M1: VTypeInfo<vfloat64m1_t, vbool64_t, 64, V_M1, f64, FPR64>;
360-
def VBF16M1: VTypeInfo<vbfloat16m1_t, vbool16_t, 16, V_M1, bf16, FPR16>;
361383
}
362384

363-
defset list<GroupVTypeInfo> GroupFloatVectors = {
364-
def VF16M2: GroupVTypeInfo<vfloat16m2_t, vfloat16m1_t, vbool8_t, 16,
365-
V_M2, f16, FPR16>;
366-
def VF16M4: GroupVTypeInfo<vfloat16m4_t, vfloat16m1_t, vbool4_t, 16,
367-
V_M4, f16, FPR16>;
368-
def VF16M8: GroupVTypeInfo<vfloat16m8_t, vfloat16m1_t, vbool2_t, 16,
369-
V_M8, f16, FPR16>;
370-
371-
def VF32M2: GroupVTypeInfo<vfloat32m2_t, vfloat32m1_t, vbool16_t, 32,
372-
V_M2, f32, FPR32>;
373-
def VF32M4: GroupVTypeInfo<vfloat32m4_t, vfloat32m1_t, vbool8_t, 32,
374-
V_M4, f32, FPR32>;
375-
def VF32M8: GroupVTypeInfo<vfloat32m8_t, vfloat32m1_t, vbool4_t, 32,
376-
V_M8, f32, FPR32>;
377-
378-
def VF64M2: GroupVTypeInfo<vfloat64m2_t, vfloat64m1_t, vbool32_t, 64,
379-
V_M2, f64, FPR64>;
380-
def VF64M4: GroupVTypeInfo<vfloat64m4_t, vfloat64m1_t, vbool16_t, 64,
381-
V_M4, f64, FPR64>;
382-
def VF64M8: GroupVTypeInfo<vfloat64m8_t, vfloat64m1_t, vbool8_t, 64,
383-
V_M8, f64, FPR64>;
384-
385-
def VBF16M2: GroupVTypeInfo<vbfloat16m2_t, vbfloat16m1_t, vbool8_t, 16,
386-
V_M2, bf16, FPR16>;
387-
def VBF16M4: GroupVTypeInfo<vbfloat16m4_t, vbfloat16m1_t, vbool4_t, 16,
388-
V_M4, bf16, FPR16>;
389-
def VBF16M8: GroupVTypeInfo<vbfloat16m8_t, vbfloat16m1_t, vbool2_t, 16,
390-
V_M8, bf16, FPR16>;
385+
defset list<VTypeInfo> AllBFloatVectors = {
386+
defset list<VTypeInfo> NoGroupBFloatVectors = {
387+
defset list<VTypeInfo> FractionalGroupBFloatVectors = {
388+
def VBF16MF4: VTypeInfo<vbfloat16mf4_t, vbool64_t, 16, V_MF4, bf16, FPR16>;
389+
def VBF16MF2: VTypeInfo<vbfloat16mf2_t, vbool32_t, 16, V_MF2, bf16, FPR16>;
390+
}
391+
def VBF16M1: VTypeInfo<vbfloat16m1_t, vbool16_t, 16, V_M1, bf16, FPR16>;
392+
}
393+
394+
defset list<GroupVTypeInfo> GroupBFloatVectors = {
395+
def VBF16M2: GroupVTypeInfo<vbfloat16m2_t, vbfloat16m1_t, vbool8_t, 16,
396+
V_M2, bf16, FPR16>;
397+
def VBF16M4: GroupVTypeInfo<vbfloat16m4_t, vbfloat16m1_t, vbool4_t, 16,
398+
V_M4, bf16, FPR16>;
399+
def VBF16M8: GroupVTypeInfo<vbfloat16m8_t, vbfloat16m1_t, vbool2_t, 16,
400+
V_M8, bf16, FPR16>;
401+
}
391402
}
392403
}
393404
}
@@ -7143,31 +7154,32 @@ defm : VPatConversionVI_VF<"int_riscv_vfclass", "PseudoVFCLASS">;
71437154
// We can use vmerge.vvm to support vector-vector vfmerge.
71447155
// NOTE: Clang previously used int_riscv_vfmerge for vector-vector, but now uses
71457156
// int_riscv_vmerge. Support both for compatibility.
7146-
foreach vti = AllFloatVectors in {
7157+
foreach vti = AllFloatAndBFloatVectors in {
71477158
let Predicates = GetVTypeMinimalPredicates<vti>.Predicates in
71487159
defm : VPatBinaryCarryInTAIL<"int_riscv_vmerge", "PseudoVMERGE", "VVM",
71497160
vti.Vector,
71507161
vti.Vector, vti.Vector, vti.Mask,
71517162
vti.Log2SEW, vti.LMul, vti.RegClass,
71527163
vti.RegClass, vti.RegClass>;
7153-
let Predicates = GetVTypePredicates<vti>.Predicates in
7154-
defm : VPatBinaryCarryInTAIL<"int_riscv_vfmerge", "PseudoVFMERGE",
7155-
"V"#vti.ScalarSuffix#"M",
7156-
vti.Vector,
7157-
vti.Vector, vti.Scalar, vti.Mask,
7158-
vti.Log2SEW, vti.LMul, vti.RegClass,
7159-
vti.RegClass, vti.ScalarRegClass>;
71607164
}
71617165

71627166
foreach fvti = AllFloatVectors in {
7163-
defvar instr = !cast<Instruction>("PseudoVMERGE_VIM_"#fvti.LMul.MX);
7164-
let Predicates = GetVTypePredicates<fvti>.Predicates in
7165-
def : Pat<(fvti.Vector (int_riscv_vfmerge (fvti.Vector fvti.RegClass:$passthru),
7166-
(fvti.Vector fvti.RegClass:$rs2),
7167-
(fvti.Scalar (fpimm0)),
7168-
(fvti.Mask VMV0:$vm), VLOpFrag)),
7169-
(instr fvti.RegClass:$passthru, fvti.RegClass:$rs2, 0,
7170-
(fvti.Mask VMV0:$vm), GPR:$vl, fvti.Log2SEW)>;
7167+
let Predicates = GetVTypePredicates<fvti>.Predicates in {
7168+
defm : VPatBinaryCarryInTAIL<"int_riscv_vfmerge", "PseudoVFMERGE",
7169+
"V"#fvti.ScalarSuffix#"M",
7170+
fvti.Vector,
7171+
fvti.Vector, fvti.Scalar, fvti.Mask,
7172+
fvti.Log2SEW, fvti.LMul, fvti.RegClass,
7173+
fvti.RegClass, fvti.ScalarRegClass>;
7174+
7175+
defvar instr = !cast<Instruction>("PseudoVMERGE_VIM_"#fvti.LMul.MX);
7176+
def : Pat<(fvti.Vector (int_riscv_vfmerge (fvti.Vector fvti.RegClass:$passthru),
7177+
(fvti.Vector fvti.RegClass:$rs2),
7178+
(fvti.Scalar (fpimm0)),
7179+
(fvti.Mask VMV0:$vm), VLOpFrag)),
7180+
(instr fvti.RegClass:$passthru, fvti.RegClass:$rs2, 0,
7181+
(fvti.Mask VMV0:$vm), GPR:$vl, fvti.Log2SEW)>;
7182+
}
71717183
}
71727184

71737185
//===----------------------------------------------------------------------===//
@@ -7328,33 +7340,27 @@ foreach vti = NoGroupIntegerVectors in {
73287340
//===----------------------------------------------------------------------===//
73297341
// 16.3. Vector Slide Instructions
73307342
//===----------------------------------------------------------------------===//
7331-
defm : VPatTernaryV_VX_VI<"int_riscv_vslideup", "PseudoVSLIDEUP", AllIntegerVectors, uimm5>;
7332-
defm : VPatTernaryV_VX_VI<"int_riscv_vslidedown", "PseudoVSLIDEDOWN", AllIntegerVectors, uimm5>;
7343+
defm : VPatTernaryV_VX_VI<"int_riscv_vslideup", "PseudoVSLIDEUP", AllVectors, uimm5>;
7344+
defm : VPatTernaryV_VX_VI<"int_riscv_vslidedown", "PseudoVSLIDEDOWN", AllVectors, uimm5>;
7345+
73337346
defm : VPatBinaryV_VX<"int_riscv_vslide1up", "PseudoVSLIDE1UP", AllIntegerVectors>;
73347347
defm : VPatBinaryV_VX<"int_riscv_vslide1down", "PseudoVSLIDE1DOWN", AllIntegerVectors>;
73357348

7336-
defm : VPatTernaryV_VX_VI<"int_riscv_vslideup", "PseudoVSLIDEUP", AllFloatVectors, uimm5>;
7337-
defm : VPatTernaryV_VX_VI<"int_riscv_vslidedown", "PseudoVSLIDEDOWN", AllFloatVectors, uimm5>;
73387349
defm : VPatBinaryV_VX<"int_riscv_vfslide1up", "PseudoVFSLIDE1UP", AllFloatVectors>;
73397350
defm : VPatBinaryV_VX<"int_riscv_vfslide1down", "PseudoVFSLIDE1DOWN", AllFloatVectors>;
73407351

73417352
//===----------------------------------------------------------------------===//
73427353
// 16.4. Vector Register Gather Instructions
73437354
//===----------------------------------------------------------------------===//
73447355
defm : VPatBinaryV_VV_VX_VI_INT<"int_riscv_vrgather", "PseudoVRGATHER",
7345-
AllIntegerVectors, uimm5>;
7356+
AllVectors, uimm5>;
73467357
defm : VPatBinaryV_VV_INT_EEW<"int_riscv_vrgatherei16_vv", "PseudoVRGATHEREI16",
7347-
eew=16, vtilist=AllIntegerVectors>;
7358+
eew=16, vtilist=AllVectors>;
73487359

7349-
defm : VPatBinaryV_VV_VX_VI_INT<"int_riscv_vrgather", "PseudoVRGATHER",
7350-
AllFloatVectors, uimm5>;
7351-
defm : VPatBinaryV_VV_INT_EEW<"int_riscv_vrgatherei16_vv", "PseudoVRGATHEREI16",
7352-
eew=16, vtilist=AllFloatVectors>;
73537360
//===----------------------------------------------------------------------===//
73547361
// 16.5. Vector Compress Instruction
73557362
//===----------------------------------------------------------------------===//
7356-
defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllIntegerVectors>;
7357-
defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllFloatVectors>;
7363+
defm : VPatUnaryV_V_AnyMask<"int_riscv_vcompress", "PseudoVCOMPRESS", AllVectors>;
73587364

73597365
// Include the non-intrinsic ISel patterns
73607366
include "RISCVInstrInfoVVLPatterns.td"

llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ defm : VPatFPSetCCSDNode_VV_VF_FV<SETOLE, "PseudoVMFLE", "PseudoVMFGE">;
13881388
// Floating-point vselects:
13891389
// 11.15. Vector Integer Merge Instructions
13901390
// 13.15. Vector Floating-Point Merge Instruction
1391-
foreach fvti = AllFloatVectors in {
1391+
foreach fvti = AllFloatAndBFloatVectors in {
13921392
defvar ivti = GetIntVTypeInfo<fvti>.Vti;
13931393
let Predicates = GetVTypePredicates<ivti>.Predicates in {
13941394
def : Pat<(fvti.Vector (vselect (fvti.Mask VMV0:$vm), fvti.RegClass:$rs1,
@@ -1397,7 +1397,12 @@ foreach fvti = AllFloatVectors in {
13971397
(fvti.Vector (IMPLICIT_DEF)),
13981398
fvti.RegClass:$rs2, fvti.RegClass:$rs1, (fvti.Mask VMV0:$vm),
13991399
fvti.AVL, fvti.Log2SEW)>;
1400+
}
1401+
}
14001402

1403+
foreach fvti = AllFloatVectors in {
1404+
defvar ivti = GetIntVTypeInfo<fvti>.Vti;
1405+
let Predicates = GetVTypePredicates<ivti>.Predicates in {
14011406
def : Pat<(fvti.Vector (vselect (fvti.Mask VMV0:$vm),
14021407
(SplatFPOp (SelectScalarFPAsInt (XLenVT GPR:$imm))),
14031408
fvti.RegClass:$rs2)),
@@ -1412,9 +1417,7 @@ foreach fvti = AllFloatVectors in {
14121417
(fvti.Vector (IMPLICIT_DEF)),
14131418
fvti.RegClass:$rs2, 0, (fvti.Mask VMV0:$vm), fvti.AVL, fvti.Log2SEW)>;
14141419
}
1415-
}
14161420

1417-
foreach fvti = AllFloatVectors in {
14181421
let Predicates = GetVTypePredicates<fvti>.Predicates in
14191422
def : Pat<(fvti.Vector (vselect (fvti.Mask VMV0:$vm),
14201423
(SplatFPOp fvti.ScalarRegClass:$rs1),

llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,10 +2423,10 @@ foreach vti = AllFloatVectors in {
24232423
}
24242424
}
24252425

2426-
foreach fvti = AllFloatVectors in {
2427-
// Floating-point vselects:
2428-
// 11.15. Vector Integer Merge Instructions
2429-
// 13.15. Vector Floating-Point Merge Instruction
2426+
// Floating-point vselects:
2427+
// 11.15. Vector Integer Merge Instructions
2428+
// 13.15. Vector Floating-Point Merge Instruction
2429+
foreach fvti = AllFloatAndBFloatVectors in {
24302430
defvar ivti = GetIntVTypeInfo<fvti>.Vti;
24312431
let Predicates = GetVTypePredicates<ivti>.Predicates in {
24322432
def : Pat<(fvti.Vector (riscv_vmerge_vl (fvti.Mask VMV0:$vm),
@@ -2437,7 +2437,12 @@ foreach fvti = AllFloatVectors in {
24372437
(!cast<Instruction>("PseudoVMERGE_VVM_"#fvti.LMul.MX)
24382438
fvti.RegClass:$passthru, fvti.RegClass:$rs2, fvti.RegClass:$rs1, (fvti.Mask VMV0:$vm),
24392439
GPR:$vl, fvti.Log2SEW)>;
2440+
}
2441+
}
24402442

2443+
foreach fvti = AllFloatVectors in {
2444+
defvar ivti = GetIntVTypeInfo<fvti>.Vti;
2445+
let Predicates = GetVTypePredicates<ivti>.Predicates in {
24412446
def : Pat<(fvti.Vector (riscv_vmerge_vl (fvti.Mask VMV0:$vm),
24422447
(SplatFPOp (SelectScalarFPAsInt (XLenVT GPR:$imm))),
24432448
fvti.RegClass:$rs2,
@@ -2457,9 +2462,7 @@ foreach fvti = AllFloatVectors in {
24572462
fvti.RegClass:$passthru, fvti.RegClass:$rs2, 0, (fvti.Mask VMV0:$vm),
24582463
GPR:$vl, fvti.Log2SEW)>;
24592464
}
2460-
}
24612465

2462-
foreach fvti = AllFloatVectors in {
24632466
let Predicates = GetVTypePredicates<fvti>.Predicates in {
24642467
def : Pat<(fvti.Vector (riscv_vmerge_vl (fvti.Mask VMV0:$vm),
24652468
(SplatFPOp fvti.ScalarRegClass:$rs1),
@@ -2767,7 +2770,7 @@ foreach vti = NoGroupFloatVectors in {
27672770
}
27682771
}
27692772

2770-
foreach vti = AllFloatVectors in {
2773+
foreach vti = AllFloatAndBFloatVectors in {
27712774
defvar ivti = GetIntVTypeInfo<vti>.Vti;
27722775
let Predicates = GetVTypePredicates<ivti>.Predicates in {
27732776
def : Pat<(vti.Vector

0 commit comments

Comments
 (0)