@@ -2872,10 +2872,10 @@ collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
2872
2872
2873
2873
// If this is a logical shift by a constant, recurse then shift the result.
2874
2874
if (I->isLogicalShift () && isa<ConstantInt>(I->getOperand (1 ))) {
2875
- unsigned BitShift =
2876
- cast<ConstantInt>(I-> getOperand ( 1 ))-> getLimitedValue (~ 0U );
2875
+ const APInt & BitShift = cast<ConstantInt>(I-> getOperand ( 1 ))-> getValue ();
2876
+
2877
2877
// Ensure the shift amount is defined.
2878
- if (BitShift > BitWidth)
2878
+ if (BitShift. uge ( BitWidth) )
2879
2879
return Result;
2880
2880
2881
2881
const auto &Res = collectBitParts (I->getOperand (0 ), MatchBSwaps,
@@ -2887,11 +2887,11 @@ collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
2887
2887
// Perform the "shift" on BitProvenance.
2888
2888
auto &P = Result->Provenance ;
2889
2889
if (I->getOpcode () == Instruction::Shl) {
2890
- P.erase (std::prev (P.end (), BitShift), P.end ());
2891
- P.insert (P.begin (), BitShift, BitPart::Unset);
2890
+ P.erase (std::prev (P.end (), BitShift. getZExtValue () ), P.end ());
2891
+ P.insert (P.begin (), BitShift. getZExtValue () , BitPart::Unset);
2892
2892
} else {
2893
- P.erase (P.begin (), std::next (P.begin (), BitShift));
2894
- P.insert (P.end (), BitShift, BitPart::Unset);
2893
+ P.erase (P.begin (), std::next (P.begin (), BitShift. getZExtValue () ));
2894
+ P.insert (P.end (), BitShift. getZExtValue () , BitPart::Unset);
2895
2895
}
2896
2896
2897
2897
return Result;
0 commit comments