Skip to content

Commit c764ee6

Browse files
authored
[RISCV] Remove custom legalization of v2i16/v4i8 loads for P extension. (#167651)
We can use the default legalization which will create an i32 load followed by a v2i32 scalar_to_vector followed by a bitcast. We can isel the scalar_to_vector like a bitcast and not generate any instructions for it.
1 parent 329dec9 commit c764ee6

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,6 +2691,16 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
26912691
}
26922692
break;
26932693
}
2694+
case ISD::SCALAR_TO_VECTOR:
2695+
if (Subtarget->enablePExtCodeGen()) {
2696+
MVT SrcVT = Node->getOperand(0).getSimpleValueType();
2697+
if (VT == MVT::v2i32 && SrcVT == MVT::i64) {
2698+
ReplaceUses(SDValue(Node, 0), Node->getOperand(0));
2699+
CurDAG->RemoveDeadNode(Node);
2700+
return;
2701+
}
2702+
}
2703+
break;
26942704
case ISD::INSERT_SUBVECTOR:
26952705
case RISCVISD::TUPLE_INSERT: {
26962706
SDValue V = Node->getOperand(0);

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,6 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
516516
setTruncStoreAction(MVT::v8i16, MVT::v8i8, Expand);
517517
setTruncStoreAction(MVT::v2i32, MVT::v2i16, Expand);
518518
setTruncStoreAction(MVT::v4i16, MVT::v4i8, Expand);
519-
setOperationAction(ISD::LOAD, MVT::v2i16, Custom);
520-
setOperationAction(ISD::LOAD, MVT::v4i8, Custom);
521519
} else {
522520
VTs.append({MVT::v2i16, MVT::v4i8});
523521
}
@@ -14757,21 +14755,6 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
1475714755
return;
1475814756
}
1475914757

14760-
if (Subtarget.is64Bit() && Subtarget.enablePExtCodeGen()) {
14761-
SDLoc DL(N);
14762-
SDValue ExtLoad =
14763-
DAG.getExtLoad(ISD::SEXTLOAD, DL, MVT::i64, Ld->getChain(),
14764-
Ld->getBasePtr(), MVT::i32, Ld->getMemOperand());
14765-
if (N->getValueType(0) == MVT::v2i16) {
14766-
Results.push_back(DAG.getBitcast(MVT::v4i16, ExtLoad));
14767-
Results.push_back(ExtLoad.getValue(1));
14768-
} else if (N->getValueType(0) == MVT::v4i8) {
14769-
Results.push_back(DAG.getBitcast(MVT::v8i8, ExtLoad));
14770-
Results.push_back(ExtLoad.getValue(1));
14771-
}
14772-
return;
14773-
}
14774-
1477514758
assert(N->getValueType(0) == MVT::i32 && Subtarget.is64Bit() &&
1477614759
"Unexpected custom legalisation");
1477714760

0 commit comments

Comments
 (0)