@@ -228,8 +228,8 @@ Index getMaxBits(Expression* curr, LocalInfoProvider* localInfoProvider) {
228228 }
229229 } else if (auto * unary = curr->dynCast <Unary>()) {
230230 switch (unary->op ) {
231- case ClzInt32: case CtzInt32: case PopcntInt32: return 5 ;
232- case ClzInt64: case CtzInt64: case PopcntInt64: return 6 ;
231+ case ClzInt32: case CtzInt32: case PopcntInt32: return 6 ;
232+ case ClzInt64: case CtzInt64: case PopcntInt64: return 7 ;
233233 case EqZInt32: case EqZInt64: return 1 ;
234234 case WrapInt64: return std::min (Index (32 ), getMaxBits (unary->value , localInfoProvider));
235235 default : {}
@@ -779,7 +779,7 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions,
779779 return ;
780780 } else if (binary->op == ShlInt32) {
781781 if (auto * c = binary->right ->dynCast <Const>()) {
782- seek (binary->left , mul * Pow2 (c-> value . geti32 ( )));
782+ seek (binary->left , mul * Pow2 (Bits::getEffectiveShifts (c )));
783783 return ;
784784 }
785785 } else if (binary->op == MulInt32) {
@@ -836,7 +836,7 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions,
836836 }
837837 } else if (curr->op == ShlInt32) {
838838 // shifting a 0 is a 0, unless the shift has side effects
839- if (left && left-> value . geti32 ( ) == 0 && !EffectAnalyzer (passOptions, curr->right ).hasSideEffects ()) {
839+ if (left && Bits::getEffectiveShifts (left ) == 0 && !EffectAnalyzer (passOptions, curr->right ).hasSideEffects ()) {
840840 replaceCurrent (left);
841841 return ;
842842 }
0 commit comments