@@ -736,25 +736,6 @@ static bool interp__builtin_expect(InterpState &S, CodePtr OpPC,
736
736
return true ;
737
737
}
738
738
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
-
758
739
static bool interp__builtin_ffs (InterpState &S, CodePtr OpPC,
759
740
const InterpFrame *Frame,
760
741
const CallExpr *Call) {
@@ -3160,7 +3141,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
3160
3141
case Builtin::BI_rotl:
3161
3142
case Builtin::BI_lrotl:
3162
3143
case Builtin::BI_rotl64:
3163
- return interp__builtin_rotate (S, OpPC, Frame, Call, /* Right=*/ false );
3144
+ return interp__builtin_elementwise_int_binop (
3145
+ S, OpPC, Call, [](const APSInt &Value, const APSInt &Amount) -> APInt {
3146
+ return Value.rotl (Amount);
3147
+ });
3164
3148
3165
3149
case Builtin::BI__builtin_rotateright8:
3166
3150
case Builtin::BI__builtin_rotateright16:
@@ -3171,7 +3155,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
3171
3155
case Builtin::BI_rotr:
3172
3156
case Builtin::BI_lrotr:
3173
3157
case Builtin::BI_rotr64:
3174
- return interp__builtin_rotate (S, OpPC, Frame, Call, /* Right=*/ true );
3158
+ return interp__builtin_elementwise_int_binop (
3159
+ S, OpPC, Call, [](const APSInt &Value, const APSInt &Amount) -> APInt {
3160
+ return Value.rotr (Amount);
3161
+ });
3175
3162
3176
3163
case Builtin::BI__builtin_ffs:
3177
3164
case Builtin::BI__builtin_ffsl:
0 commit comments