@@ -5337,26 +5337,23 @@ LegalizerHelper::narrowScalarMul(MachineInstr &MI, LLT NarrowTy) {
5337
5337
if (Ty.isVector ())
5338
5338
return UnableToLegalize;
5339
5339
5340
- unsigned SrcSize = MRI.getType (Src1).getSizeInBits ();
5341
- unsigned DstSize = Ty.getSizeInBits ();
5340
+ unsigned Size = Ty.getSizeInBits ();
5342
5341
unsigned NarrowSize = NarrowTy.getSizeInBits ();
5343
- if (DstSize % NarrowSize != 0 || SrcSize % NarrowSize != 0 )
5342
+ if (Size % NarrowSize != 0 )
5344
5343
return UnableToLegalize;
5345
5344
5346
- unsigned NumDstParts = DstSize / NarrowSize;
5347
- unsigned NumSrcParts = SrcSize / NarrowSize;
5345
+ unsigned NumParts = Size / NarrowSize;
5348
5346
bool IsMulHigh = MI.getOpcode () == TargetOpcode::G_UMULH;
5349
- unsigned DstTmpParts = NumDstParts * (IsMulHigh ? 2 : 1 );
5347
+ unsigned DstTmpParts = NumParts * (IsMulHigh ? 2 : 1 );
5350
5348
5351
5349
SmallVector<Register, 2 > Src1Parts, Src2Parts;
5352
5350
SmallVector<Register, 2 > DstTmpRegs (DstTmpParts);
5353
- extractParts (Src1, NarrowTy, NumSrcParts , Src1Parts);
5354
- extractParts (Src2, NarrowTy, NumSrcParts , Src2Parts);
5351
+ extractParts (Src1, NarrowTy, NumParts , Src1Parts);
5352
+ extractParts (Src2, NarrowTy, NumParts , Src2Parts);
5355
5353
multiplyRegisters (DstTmpRegs, Src1Parts, Src2Parts, NarrowTy);
5356
5354
5357
5355
// Take only high half of registers if this is high mul.
5358
- ArrayRef<Register> DstRegs (
5359
- IsMulHigh ? &DstTmpRegs[DstTmpParts / 2 ] : &DstTmpRegs[0 ], NumDstParts);
5356
+ ArrayRef<Register> DstRegs (&DstTmpRegs[DstTmpParts - NumParts], NumParts);
5360
5357
MIRBuilder.buildMerge (DstReg, DstRegs);
5361
5358
MI.eraseFromParent ();
5362
5359
return Legalized;
0 commit comments