[APInt] In udivrem, remember the bit width in a local variable so we don't reread it from the LHS which might be aliased with Quotient or Remainder.
This helped the compiler generate better code for the single word case. It was able to remember that the bit width was still a single word when it created the Remainder APInt and not create code for it possibly being multiword.
gitsvnid: https://llvm.org/svn/llvmproject/llvm/trunk@302952 911773080d340410b5e696231b3b80d8
Craig Topper
3 years ago
1647  1647  void APInt::udivrem(const APInt &LHS, const APInt &RHS, 
1648  1648  APInt &Quotient, APInt &Remainder) { 
1649  1649  assert(LHS.BitWidth == RHS.BitWidth && "Bit widths must be the same"); 
1650  unsigned BitWidth = LHS.BitWidth;  
1650  1651  
1651  1652  // First, deal with the easy case 
1652  1653  if (LHS.isSingleWord()) { 
1653  1654  assert(RHS.U.VAL != 0 && "Divide by zero?"); 
1654  1655  uint64_t QuotVal = LHS.U.VAL / RHS.U.VAL; 
1655  1656  uint64_t RemVal = LHS.U.VAL % RHS.U.VAL; 
1656  Quotient = APInt(LHS.BitWidth, QuotVal);  
1657 


1657  Quotient = APInt(BitWidth, QuotVal);⏎  
1658  Remainder = APInt(BitWidth, RemVal);  
1658  1659  return; 
1659  1660  } 
1660  1661  
1687  1688  uint64_t lhsValue = LHS.U.pVal[0]; 
1688  1689  uint64_t rhsValue = RHS.U.pVal[0]; 
1689  1690  // Make sure there is enough space to hold the results. 
1690  Quotient.reallocate(LHS.BitWidth);  
1691 


1691  Quotient.reallocate(BitWidth);⏎  
1692  Remainder.reallocate(BitWidth);  
1692  1693  Quotient = lhsValue / rhsValue; 
1693  1694  Remainder = lhsValue % rhsValue; 
1694  1695  return; 