Skip to content

Commit 3101e25

Browse files
committed
[MIPS][MSA] Widen v2 vectors to the register length for MIPS64 w/ MSA
Currently v2i8, v2i16 and v2i32 are being promoted to v2i64 which casts the vector back and forth. Widening them to avoid unnecessary bitcasts, loads and stores.
1 parent 5dcdaa5 commit 3101e25

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

llvm/lib/Target/Mips/MipsSEISelLowering.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ static cl::opt<bool> NoDPLoadStore("mno-ldc1-sdc1", cl::init(false),
5959
"stores to their single precision "
6060
"counterparts"));
6161

62+
// Widen the v2 vectors to the register width, i.e. v2i16 -> v8i16,
63+
// v2i32 -> v4i32, etc, to ensure the correct rail size is used.
64+
// We will deal with incorrect pattern being matched problem later.
65+
TargetLoweringBase::LegalizeTypeAction
66+
MipsSETargetLowering::getPreferredVectorAction(MVT VT) const {
67+
if (this->Subtarget.hasMSA() && this->Subtarget.isGP64bit()) {
68+
switch (VT.SimpleTy) {
69+
// Leave v2i1s to be promoted to larger ones.
70+
case MVT::v2i1:
71+
return TypePromoteInteger;
72+
case MVT::v2i8:
73+
case MVT::v2i16:
74+
case MVT::v2i32:
75+
return TypeWidenVector;
76+
break;
77+
// v2i64 is already 128-bit wide.
78+
default:
79+
break;
80+
}
81+
}
82+
return TargetLoweringBase::getPreferredVectorAction(VT);
83+
}
84+
6285
MipsSETargetLowering::MipsSETargetLowering(const MipsTargetMachine &TM,
6386
const MipsSubtarget &STI)
6487
: MipsTargetLowering(TM, STI) {

llvm/lib/Target/Mips/MipsSEISelLowering.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class TargetRegisterClass;
4545
MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
4646
unsigned *Fast = nullptr) const override;
4747

48+
TargetLoweringBase::LegalizeTypeAction
49+
getPreferredVectorAction(MVT VT) const override;
50+
4851
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
4952

5053
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;

0 commit comments

Comments
 (0)