Skip to content

Commit ff6f790

Browse files
committed
[5/11][Clang][RISCV] Expand all variants for unit stride fault-first segment load
This is the 5th patch of the patch-set. For the cover letter, please checkout D152069. Depends on D152072. This patch expands all variants of unit stride fault-first segment load, including the policy variants. This patch also fixes the trailing suffix in the intrinsics' function name that representing the return type, adding `x{NF}`. For the same reason mentioned in [3/11], only full test case for vlseg2e32ff is added. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D152073
1 parent d90468d commit ff6f790

File tree

5 files changed

+2526
-19
lines changed

5 files changed

+2526
-19
lines changed

clang/include/clang/Basic/riscv_vector.td

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,28 +1617,39 @@ multiclass RVVUnitStridedSegStoreTuple<string op> {
16171617
}
16181618

16191619
multiclass RVVUnitStridedSegLoadFFTuple<string op> {
1620-
foreach type = ["i"] in {
1621-
defvar eew = !cond(!eq(type, "i") : "32");
1622-
foreach nf = [2] in {
1620+
foreach type = TypeList in {
1621+
defvar eew = !cond(!eq(type, "c") : "8",
1622+
!eq(type, "s") : "16",
1623+
!eq(type, "i") : "32",
1624+
!eq(type, "l") : "64",
1625+
!eq(type, "x") : "16",
1626+
!eq(type, "f") : "32",
1627+
!eq(type, "d") : "64");
1628+
foreach nf = NFList in {
16231629
let Name = op # nf # "e" # eew # "ff_v_tuple",
16241630
OverloadedName = op # nf # "e" # eew # "ff_tuple",
16251631
IRName = op # nf # "ff",
16261632
MaskedIRName = op # nf # "ff_mask",
16271633
NF = nf,
16281634
ManualCodegen = [{
16291635
{
1630-
assert(((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
1631-
(!IsMasked && (PolicyAttrs & RVV_VTA))) &&
1632-
"FIXME: Only handling default policy (TAMA) for now");
1633-
16341636
llvm::Type *ElementVectorType = cast<StructType>(ResultType)->elements()[0];
1635-
16361637
IntrinsicTypes = {ElementVectorType, Ops.back()->getType()};
16371638
SmallVector<llvm::Value*, 12> Operands;
16381639

1639-
Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
1640+
bool NoPassthru =
1641+
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
1642+
(!IsMasked && (PolicyAttrs & RVV_VTA));
1643+
unsigned Offset = IsMasked ? NoPassthru ? 1 : 2 : NoPassthru ? 0 : 1;
1644+
1645+
if (NoPassthru) { // Push poison into passthru
1646+
Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
1647+
} else { // Push intrinsics operands into passthru
1648+
llvm::Value *PassthruOperand = IsMasked ? Ops[1] : Ops[0];
1649+
for (unsigned I = 0; I < NF; ++I)
1650+
Operands.push_back(Builder.CreateExtractValue(PassthruOperand, {I}));
1651+
}
16401652

1641-
unsigned Offset = IsMasked ? 1 : 0;
16421653
Operands.push_back(Ops[Offset]); // Ptr
16431654
if (IsMasked)
16441655
Operands.push_back(Ops[0]);
@@ -1669,8 +1680,11 @@ multiclass RVVUnitStridedSegLoadFFTuple<string op> {
16691680
return Builder.CreateStore(ReturnTuple, ReturnValue.getValue());
16701681
}
16711682
}] in {
1672-
defvar T = "(Tuple:" # nf # ")";
1673-
def : RVVBuiltin<"v", T # "vPCePz", type>;
1683+
defvar T = "(Tuple:" # nf # ")";
1684+
def : RVVBuiltin<T # "v", T # "vPCePz", type>;
1685+
if !not(IsFloat<type>.val) then {
1686+
def : RVVBuiltin<T # "Uv", T # "UvPCUePz", type>;
1687+
}
16741688
}
16751689
}
16761690
}
@@ -1871,13 +1885,13 @@ multiclass RVVIndexedSegStoreTuple<string op> {
18711885
let UnMaskedPolicyScheme = HasPassthruOperand,
18721886
IsTuple = true in {
18731887
defm : RVVUnitStridedSegLoadTuple<"vlseg">;
1888+
defm : RVVUnitStridedSegLoadFFTuple<"vlseg">;
18741889
}
18751890

18761891
// TODO: Extend for policy
18771892
let UnMaskedPolicyScheme = NonePolicy,
18781893
MaskedPolicyScheme = NonePolicy,
18791894
IsTuple = true in {
1880-
defm : RVVUnitStridedSegLoadFFTuple<"vlseg">;
18811895
defm : RVVStridedSegLoadTuple<"vlsseg">;
18821896
defm : RVVIndexedSegLoadTuple<"vluxseg">;
18831897
defm : RVVIndexedSegLoadTuple<"vloxseg">;

0 commit comments

Comments
 (0)