Skip to content

Commit c1f3a38

Browse files
committed
support fadd, fsub, fmul, fma and load on v2f32
1 parent c39870f commit c1f3a38

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,10 +1113,14 @@ bool NVPTXDAGToDAGISel::tryLoad(SDNode *N) {
11131113
// Vector Setting
11141114
unsigned VecType = NVPTX::PTXLdStInstCode::Scalar;
11151115
if (SimpleVT.isVector()) {
1116-
assert((Isv2x16VT(LoadedVT) || LoadedVT == MVT::v4i8) &&
1117-
"Unexpected vector type");
1118-
// v2f16/v2bf16/v2i16 is loaded using ld.b32
1119-
FromTypeWidth = 32;
1116+
if (Isv2x16VT(LoadedVT) || LoadedVT == MVT::v4i8)
1117+
// v2f16/v2bf16/v2i16 is loaded using ld.b32
1118+
FromTypeWidth = 32;
1119+
else if (LoadedVT == MVT::v2f32)
1120+
// v2f32 is loaded using ld.b64
1121+
FromTypeWidth = 64;
1122+
else
1123+
llvm_unreachable("Unexpected vector type");
11201124
}
11211125

11221126
if (PlainLoad && (PlainLoad->getExtensionType() == ISD::SEXTLOAD))

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,18 @@ multiclass F3<string op_str, SDPatternOperator op_pat> {
411411
(ins Float32Regs:$a, f32imm:$b),
412412
op_str # ".f32 \t$dst, $a, $b;",
413413
[(set f32:$dst, (op_pat f32:$a, fpimm:$b))]>;
414-
414+
def f32x2rr_ftz :
415+
NVPTXInst<(outs Int64Regs:$dst),
416+
(ins Int64Regs:$a, Int64Regs:$b),
417+
op_str # ".ftz.f32x2 \t$dst, $a, $b;",
418+
[(set v2f32:$dst, (op_pat v2f32:$a, v2f32:$b))]>,
419+
Requires<[doF32FTZ, hasF32x2Instructions]>;
420+
def f32x2rr :
421+
NVPTXInst<(outs Int64Regs:$dst),
422+
(ins Int64Regs:$a, Int64Regs:$b),
423+
op_str # ".f32x2 \t$dst, $a, $b;",
424+
[(set v2f32:$dst, (op_pat v2f32:$a, v2f32:$b))]>,
425+
Requires<[hasF32x2Instructions]>;
415426
def f16rr_ftz :
416427
NVPTXInst<(outs Int16Regs:$dst),
417428
(ins Int16Regs:$a, Int16Regs:$b),
@@ -443,7 +454,6 @@ multiclass F3<string op_str, SDPatternOperator op_pat> {
443454
op_str # ".bf16 \t$dst, $a, $b;",
444455
[(set bf16:$dst, (op_pat bf16:$a, bf16:$b))]>,
445456
Requires<[hasBF16Math]>;
446-
447457
def bf16x2rr :
448458
NVPTXInst<(outs Int32Regs:$dst),
449459
(ins Int32Regs:$a, Int32Regs:$b),
@@ -1335,6 +1345,13 @@ multiclass FMA_BF16<string OpcStr, ValueType T, RegisterClass RC, Predicate Pred
13351345
Requires<[hasBF16Math, Pred]>;
13361346
}
13371347

1348+
class FMA_F32x2<string OpcStr, Predicate Pred>
1349+
: NVPTXInst<(outs Int64Regs:$res),
1350+
(ins Int64Regs:$a, Int64Regs:$b, Int64Regs:$c),
1351+
OpcStr # ".f32x2 \t$res, $a, $b, $c;",
1352+
[(set v2f32:$res, (fma v2f32:$a, v2f32:$b, v2f32:$c))]>,
1353+
Requires<[hasF32x2Instructions, Pred]>;
1354+
13381355
defm FMA16_ftz : FMA_F16<"fma.rn.ftz.f16", f16, Int16Regs, doF32FTZ>;
13391356
defm FMA16 : FMA_F16<"fma.rn.f16", f16, Int16Regs, True>;
13401357
defm FMA16x2_ftz : FMA_F16<"fma.rn.ftz.f16x2", v2f16, Int32Regs, doF32FTZ>;
@@ -1343,6 +1360,8 @@ defm BFMA16 : FMA_BF16<"fma.rn.bf16", bf16, Int16Regs, True>;
13431360
defm BFMA16x2 : FMA_BF16<"fma.rn.bf16x2", v2bf16, Int32Regs, True>;
13441361
defm FMA32_ftz : FMA<"fma.rn.ftz.f32", Float32Regs, f32imm, doF32FTZ>;
13451362
defm FMA32 : FMA<"fma.rn.f32", Float32Regs, f32imm, True>;
1363+
def FMA32x2_ftz : FMA_F32x2<"fma.rn.ftz", doF32FTZ>;
1364+
def FMA32x2 : FMA_F32x2<"fma.rn", True>;
13461365
defm FMA64 : FMA<"fma.rn.f64", Float64Regs, f64imm, True>;
13471366

13481367
// sin/cos

0 commit comments

Comments
 (0)