Skip to content

Commit cb7030d

Browse files
authored
[LoongArch] use TypeWidenVector for most illegal vector types (llvm#126456)
`TypeWidenVector` makes an illegal vector a larger one e.g. in lsx v2i32 -> v4i32 v4i16 -> v8i16 With this we can make good use of `vilvh`, `vilvl` instructions in vector `sext`, `zext` in later pr. Previous action is `TypePromoteInteger`, which replaces integer with a larger one e.g. in lsx v2i32 -> v2i64 v4i16 -> v4i32
1 parent f5f3612 commit cb7030d

File tree

4 files changed

+294
-439
lines changed

4 files changed

+294
-439
lines changed

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6570,3 +6570,12 @@ bool LoongArchTargetLowering::shouldAlignPointerArgs(CallInst *CI,
65706570

65716571
return true;
65726572
}
6573+
6574+
TargetLoweringBase::LegalizeTypeAction
6575+
LoongArchTargetLowering::getPreferredVectorAction(MVT VT) const {
6576+
if (!VT.isScalableVector() && VT.getVectorNumElements() != 1 &&
6577+
VT.getVectorElementType() != MVT::i1)
6578+
return TypeWidenVector;
6579+
6580+
return TargetLoweringBase::getPreferredVectorAction(VT);
6581+
}

llvm/lib/Target/LoongArch/LoongArchISelLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ class LoongArchTargetLowering : public TargetLowering {
281281
Align &PrefAlign) const override;
282282

283283
bool isFPImmVLDILegal(const APFloat &Imm, EVT VT) const;
284+
LegalizeTypeAction getPreferredVectorAction(MVT VT) const override;
284285

285286
private:
286287
/// Target-specific function used to lower LoongArch calling conventions.

0 commit comments

Comments
 (0)