@@ -1513,6 +1513,7 @@ static bool foldMulHigh(Instruction &I) {
15131513 Value *Mul = Builder.CreateMul (XExt, YExt);
15141514 Value *High = Builder.CreateLShr (Mul, BW);
15151515 Value *Res = Builder.CreateTrunc (High, Ty);
1516+ Res->takeName (&I);
15161517 I.replaceAllUsesWith (Res);
15171518 LLVM_DEBUG (dbgs () << " Created long multiply from parts of " << *X << " and "
15181519 << *Y << " \n " );
@@ -1529,20 +1530,20 @@ static bool foldMulHigh(Instruction &I) {
15291530 m_And (m_Specific (Y), m_SpecificInt (LowMask))));
15301531 };
15311532
1532- auto foldMulHighCarry = [&](Value *X, Value *Y, Instruction *Carry,
1533+ auto FoldMulHighCarry = [&](Value *X, Value *Y, Instruction *Carry,
15331534 Instruction *B) {
15341535 // Looking for LowSum >> 32 and carry (select)
15351536 if (Carry->getOpcode () != Instruction::Select)
15361537 std::swap (Carry, B);
15371538
15381539 // Carry = LowSum < XhYl ? 0x100000000 : 0
1539- CmpPredicate Pred;
15401540 Value *LowSum, *XhYl;
15411541 if (!match (Carry,
15421542 m_OneUse (m_Select (
1543- m_OneUse (m_ICmp (Pred, m_Value (LowSum), m_Value (XhYl))),
1544- m_SpecificInt (APInt (BW, 1 ) << BW / 2 ), m_SpecificInt (0 )))) ||
1545- Pred != ICmpInst::ICMP_ULT)
1543+ m_OneUse (m_SpecificICmp (ICmpInst::ICMP_ULT, m_Value (LowSum),
1544+ m_Value (XhYl))),
1545+ m_SpecificInt (APInt::getOneBitSet (BW, BW / 2 )),
1546+ m_SpecificInt (0 )))))
15461547 return false ;
15471548
15481549 // XhYl can be Xh*Yl or Xl*Yh
@@ -1583,7 +1584,7 @@ static bool foldMulHigh(Instruction &I) {
15831584 return CreateMulHigh (X, Y);
15841585 };
15851586
1586- auto foldMulHighLadder = [&](Value *X, Value *Y, Instruction *A,
1587+ auto FoldMulHighLadder = [&](Value *X, Value *Y, Instruction *A,
15871588 Instruction *B) {
15881589 // xh*yh + c2>>32 + c3>>32
15891590 // c2 = xh*yl + (xl*yl >> 32); c3 = c2&0xffffffff + xl*yh
@@ -1622,7 +1623,7 @@ static bool foldMulHigh(Instruction &I) {
16221623 return CreateMulHigh (X, Y);
16231624 };
16241625
1625- auto foldMulHighLadder4 = [&](Value *X, Value *Y, Instruction *A,
1626+ auto FoldMulHighLadder4 = [&](Value *X, Value *Y, Instruction *A,
16261627 Instruction *B, Instruction *C) {
16271628 // / Ladder4: xh*yh + (xl*yh)>>32 + (xh+yl)>>32 + low>>32;
16281629 // / low = (xl*yl)>>32 + (xl*yh)&0xffffffff + (xh*yl)&0xffffffff
@@ -1679,7 +1680,7 @@ static bool foldMulHigh(Instruction &I) {
16791680 return CreateMulHigh (X, Y);
16801681 };
16811682
1682- auto foldMulHighCarry4 = [&](Value *X, Value *Y, Instruction *Carry,
1683+ auto FoldMulHighCarry4 = [&](Value *X, Value *Y, Instruction *Carry,
16831684 Instruction *B, Instruction *C) {
16841685 // xh*yh + carry + crosssum>>32 + (xl*yl + crosssum&0xffffffff) >> 32
16851686 // crosssum = xh*yl+xl*yh
@@ -1690,13 +1691,13 @@ static bool foldMulHigh(Instruction &I) {
16901691 std::swap (Carry, C);
16911692
16921693 // Carry = CrossSum < XhYl ? 0x100000000 : 0
1693- CmpPredicate Pred;
16941694 Value *CrossSum, *XhYl;
16951695 if (!match (Carry,
16961696 m_OneUse (m_Select (
1697- m_OneUse (m_ICmp (Pred, m_Value (CrossSum), m_Value (XhYl))),
1698- m_SpecificInt (APInt (BW, 1 ) << BW / 2 ), m_SpecificInt (0 )))) ||
1699- Pred != ICmpInst::ICMP_ULT)
1697+ m_OneUse (m_SpecificICmp (ICmpInst::ICMP_ULT,
1698+ m_Value (CrossSum), m_Value (XhYl))),
1699+ m_SpecificInt (APInt::getOneBitSet (BW, BW / 2 )),
1700+ m_SpecificInt (0 )))))
17001701 return false ;
17011702
17021703 if (!match (B, m_LShr (m_Specific (CrossSum), m_SpecificInt (BW / 2 ))))
@@ -1741,7 +1742,7 @@ static bool foldMulHigh(Instruction &I) {
17411742 match (&I, m_c_Add (m_Instruction (A),
17421743 m_OneUse (m_c_Add (HiHi, m_Instruction (B)))))) &&
17431744 A->hasOneUse () && B->hasOneUse ())
1744- if (foldMulHighCarry (X, Y, A, B) || foldMulHighLadder (X, Y, A, B))
1745+ if (FoldMulHighCarry (X, Y, A, B) || FoldMulHighLadder (X, Y, A, B))
17451746 return true ;
17461747
17471748 if ((match (&I, m_c_Add (HiHi, m_OneUse (m_c_Add (
@@ -1760,8 +1761,8 @@ static bool foldMulHigh(Instruction &I) {
17601761 m_c_Add (m_OneUse (m_c_Add (HiHi, m_Instruction (A))),
17611762 m_OneUse (m_Add (m_Instruction (B), m_Instruction (C)))))) &&
17621763 A->hasOneUse () && B->hasOneUse () && C->hasOneUse ())
1763- return foldMulHighCarry4 (X, Y, A, B, C) ||
1764- foldMulHighLadder4 (X, Y, A, B, C);
1764+ return FoldMulHighCarry4 (X, Y, A, B, C) ||
1765+ FoldMulHighLadder4 (X, Y, A, B, C);
17651766
17661767 return false ;
17671768}
0 commit comments