mirror of
https://github.com/intel/llvm.git
synced 2026-02-04 20:00:11 +08:00
[GlobalISel] Simplify narrowScalarMul. NFC.
Remove some redundancy because the source and result types of any multiply are always the same.
This commit is contained in:
@@ -5337,26 +5337,23 @@ LegalizerHelper::narrowScalarMul(MachineInstr &MI, LLT NarrowTy) {
|
||||
if (Ty.isVector())
|
||||
return UnableToLegalize;
|
||||
|
||||
unsigned SrcSize = MRI.getType(Src1).getSizeInBits();
|
||||
unsigned DstSize = Ty.getSizeInBits();
|
||||
unsigned Size = Ty.getSizeInBits();
|
||||
unsigned NarrowSize = NarrowTy.getSizeInBits();
|
||||
if (DstSize % NarrowSize != 0 || SrcSize % NarrowSize != 0)
|
||||
if (Size % NarrowSize != 0)
|
||||
return UnableToLegalize;
|
||||
|
||||
unsigned NumDstParts = DstSize / NarrowSize;
|
||||
unsigned NumSrcParts = SrcSize / NarrowSize;
|
||||
unsigned NumParts = Size / NarrowSize;
|
||||
bool IsMulHigh = MI.getOpcode() == TargetOpcode::G_UMULH;
|
||||
unsigned DstTmpParts = NumDstParts * (IsMulHigh ? 2 : 1);
|
||||
unsigned DstTmpParts = NumParts * (IsMulHigh ? 2 : 1);
|
||||
|
||||
SmallVector<Register, 2> Src1Parts, Src2Parts;
|
||||
SmallVector<Register, 2> DstTmpRegs(DstTmpParts);
|
||||
extractParts(Src1, NarrowTy, NumSrcParts, Src1Parts);
|
||||
extractParts(Src2, NarrowTy, NumSrcParts, Src2Parts);
|
||||
extractParts(Src1, NarrowTy, NumParts, Src1Parts);
|
||||
extractParts(Src2, NarrowTy, NumParts, Src2Parts);
|
||||
multiplyRegisters(DstTmpRegs, Src1Parts, Src2Parts, NarrowTy);
|
||||
|
||||
// Take only high half of registers if this is high mul.
|
||||
ArrayRef<Register> DstRegs(
|
||||
IsMulHigh ? &DstTmpRegs[DstTmpParts / 2] : &DstTmpRegs[0], NumDstParts);
|
||||
ArrayRef<Register> DstRegs(&DstTmpRegs[DstTmpParts - NumParts], NumParts);
|
||||
MIRBuilder.buildMerge(DstReg, DstRegs);
|
||||
MI.eraseFromParent();
|
||||
return Legalized;
|
||||
|
||||
Reference in New Issue
Block a user