[llvm] GlobalISel: Use G_UADDE when narrowing G_UMULH (PR #97194)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 08:34:05 PDT 2024
================
@@ -5755,15 +5758,15 @@ void LegalizerHelper::multiplyRegisters(SmallVectorImpl<Register> &DstRegs,
// Add all factors and accumulate all carries into CarrySum.
if (DstIdx != DstParts - 1) {
MachineInstrBuilder Uaddo =
- B.buildUAddo(NarrowTy, LLT::scalar(1), Factors[0], Factors[1]);
+ B.buildUAddo(NarrowTy, S1, Factors[0], Factors[1]);
FactorSum = Uaddo.getReg(0);
- CarrySum = B.buildZExt(NarrowTy, Uaddo.getReg(1)).getReg(0);
+ CarrySum = Zero;
for (unsigned i = 2; i < Factors.size(); ++i) {
- MachineInstrBuilder Uaddo =
- B.buildUAddo(NarrowTy, LLT::scalar(1), FactorSum, Factors[i]);
- FactorSum = Uaddo.getReg(0);
- MachineInstrBuilder Carry = B.buildZExt(NarrowTy, Uaddo.getReg(1));
- CarrySum = B.buildAdd(NarrowTy, CarrySum, Carry).getReg(0);
+ auto Uadde =
+ B.buildUAdde(NarrowTy, S1, FactorSum, Factors[i], Uaddo.getReg(1));
----------------
jayfoad wrote:
No, this one should stay as a uaddo. The carry output from the original uaddo (outside the loop) should go into CarrySum once, but you're adding it into FactorSum every time around this loop.
https://github.com/llvm/llvm-project/pull/97194
More information about the llvm-commits
mailing list