@@ -611,7 +611,7 @@ struct LoadOps {
611
611
LoadInst *RootInsert = nullptr ;
612
612
bool FoundRoot = false ;
613
613
uint64_t LoadSize = 0 ;
614
- Value *Shift = nullptr ;
614
+ const APInt *Shift = nullptr ;
615
615
Type *ZextType;
616
616
AAMDNodes AATags;
617
617
};
@@ -621,15 +621,15 @@ struct LoadOps {
621
621
// (ZExt(L1) << shift1) | ZExt(L2) -> ZExt(L3)
622
622
static bool foldLoadsRecursive (Value *V, LoadOps &LOps, const DataLayout &DL,
623
623
AliasAnalysis &AA) {
624
- Value *ShAmt2 = nullptr ;
624
+ const APInt *ShAmt2 = nullptr ;
625
625
Value *X;
626
626
Instruction *L1, *L2;
627
627
628
628
// Go to the last node with loads.
629
629
if (match (V, m_OneUse (m_c_Or (
630
630
m_Value (X),
631
631
m_OneUse (m_Shl (m_OneUse (m_ZExt (m_OneUse (m_Instruction (L2)))),
632
- m_Value (ShAmt2)))))) ||
632
+ m_APInt (ShAmt2)))))) ||
633
633
match (V, m_OneUse (m_Or (m_Value (X),
634
634
m_OneUse (m_ZExt (m_OneUse (m_Instruction (L2)))))))) {
635
635
if (!foldLoadsRecursive (X, LOps, DL, AA) && LOps.FoundRoot )
@@ -640,11 +640,11 @@ static bool foldLoadsRecursive(Value *V, LoadOps &LOps, const DataLayout &DL,
640
640
641
641
// Check if the pattern has loads
642
642
LoadInst *LI1 = LOps.Root ;
643
- Value *ShAmt1 = LOps.Shift ;
643
+ const APInt *ShAmt1 = LOps.Shift ;
644
644
if (LOps.FoundRoot == false &&
645
645
(match (X, m_OneUse (m_ZExt (m_Instruction (L1)))) ||
646
646
match (X, m_OneUse (m_Shl (m_OneUse (m_ZExt (m_OneUse (m_Instruction (L1)))),
647
- m_Value (ShAmt1)))))) {
647
+ m_APInt (ShAmt1)))))) {
648
648
LI1 = dyn_cast<LoadInst>(L1);
649
649
}
650
650
LoadInst *LI2 = dyn_cast<LoadInst>(L2);
@@ -719,12 +719,11 @@ static bool foldLoadsRecursive(Value *V, LoadOps &LOps, const DataLayout &DL,
719
719
std::swap (ShAmt1, ShAmt2);
720
720
721
721
// Find Shifts values.
722
- const APInt *Temp;
723
722
uint64_t Shift1 = 0 , Shift2 = 0 ;
724
- if (ShAmt1 && match (ShAmt1, m_APInt (Temp)) )
725
- Shift1 = Temp ->getZExtValue ();
726
- if (ShAmt2 && match (ShAmt2, m_APInt (Temp)) )
727
- Shift2 = Temp ->getZExtValue ();
723
+ if (ShAmt1)
724
+ Shift1 = ShAmt1 ->getZExtValue ();
725
+ if (ShAmt2)
726
+ Shift2 = ShAmt2 ->getZExtValue ();
728
727
729
728
// First load is always LI1. This is where we put the new load.
730
729
// Use the merged load size available from LI1 for forward loads.
@@ -816,7 +815,7 @@ static bool foldConsecutiveLoads(Instruction &I, const DataLayout &DL,
816
815
// Check if shift needed. We need to shift with the amount of load1
817
816
// shift if not zero.
818
817
if (LOps.Shift )
819
- NewOp = Builder.CreateShl (NewOp, LOps.Shift );
818
+ NewOp = Builder.CreateShl (NewOp, ConstantInt::get (I. getContext (), * LOps.Shift ) );
820
819
I.replaceAllUsesWith (NewOp);
821
820
822
821
return true ;
0 commit comments