Skip to content

Commit 1132144

Browse files
committed
#160289 computed amount as B.urem(A.getBitWidth()) to match previouse behavior, and removed interp__builtin_rotate which is now unused
1 parent ffb2a3f commit 1132144

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
758739
static 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

Comments
 (0)