@@ -736,25 +736,6 @@ static bool interp__builtin_expect(InterpState &S, CodePtr OpPC,
736736 return true ;
737737}
738738
739- // / rotateleft(value, amount)
740- static bool interp__builtin_rotate (InterpState &S, CodePtr OpPC,
741- const InterpFrame *Frame,
742- const CallExpr *Call, bool Right) {
743- APSInt Amount = popToAPSInt (S, Call->getArg (1 ));
744- APSInt Value = popToAPSInt (S, Call->getArg (0 ));
745-
746- APSInt Result;
747- if (Right)
748- Result = APSInt (Value.rotr (Amount.urem (Value.getBitWidth ())),
749- /* IsUnsigned=*/ true );
750- else // Left.
751- Result = APSInt (Value.rotl (Amount.urem (Value.getBitWidth ())),
752- /* IsUnsigned=*/ true );
753-
754- pushInteger (S, Result, Call->getType ());
755- return true ;
756- }
757-
758739static bool interp__builtin_ffs (InterpState &S, CodePtr OpPC,
759740 const InterpFrame *Frame,
760741 const CallExpr *Call) {
@@ -3164,7 +3145,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
31643145 case Builtin::BI_rotl64:
31653146 return interp__builtin_elementwise_int_binop (
31663147 S, OpPC, Call, [](const APSInt &A, const APSInt &B) -> APInt {
3167- return A.rotl (( unsigned )B. getLimitedValue ( ));
3148+ return A.rotl (B. urem (A. getBitWidth () ));
31683149 });
31693150
31703151 case Builtin::BI__builtin_rotateright8:
@@ -3178,7 +3159,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
31783159 case Builtin::BI_rotr64:
31793160 return interp__builtin_elementwise_int_binop (
31803161 S, OpPC, Call, [](const APSInt &A, const APSInt &B) -> APInt {
3181- return A.rotr (( unsigned )B. getLimitedValue ( ));
3162+ return A.rotr (B. urem (A. getBitWidth () ));
31823163 });
31833164
31843165 case Builtin::BI__builtin_ffs:
0 commit comments