Skip to content

Commit d4ea868

Browse files
committed
handle special case 8 in interp__builtin_bswap and fix extra space in VisitBuiltinCallExpr
1 parent 92466f3 commit d4ea868

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,10 @@ static bool interp__builtin_bswap(InterpState &S, CodePtr OpPC,
10041004
const CallExpr *Call) {
10051005
const APSInt &Val = popToAPSInt(S, Call->getArg(0));
10061006
assert(Val.getActiveBits() <= 64);
1007-
1008-
pushInteger(S, Val.byteSwap(), Call->getType());
1007+
if (Val.getBitWidth() == 8)
1008+
pushInteger(S, Val, Call->getType());
1009+
else
1010+
pushInteger(S, Val.byteSwap(), Call->getType());
10091011
return true;
10101012
}
10111013

@@ -3288,15 +3290,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
32883290
case Builtin::BI__builtin_elementwise_ctzg:
32893291
return interp__builtin_elementwise_countzeroes(S, OpPC, Frame, Call,
32903292
BuiltinID);
3291-
case Builtin::BI__builtin_bswapg: {
3292-
const APSInt &Val = popToAPSInt(S, Call->getArg(0));
3293-
assert(Val.getActiveBits() <= 64);
3294-
if (Val.getBitWidth() == 8)
3295-
pushInteger(S, Val, Call->getType());
3296-
else
3297-
pushInteger(S, Val.byteSwap(), Call->getType());
3298-
return true;
3299-
}
3293+
case Builtin::BI__builtin_bswapg:
33003294
case Builtin::BI__builtin_bswap16:
33013295
case Builtin::BI__builtin_bswap32:
33023296
case Builtin::BI__builtin_bswap64:

clang/lib/AST/ExprConstant.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13986,10 +13986,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1398613986
APSInt Val;
1398713987
if (!EvaluateInteger(E->getArg(0), Val, Info))
1398813988
return false;
13989-
if (Val.getBitWidth() == 8) {
13990-
bool ret = Success(Val, E);
13991-
return ret;
13992-
}
13989+
if (Val.getBitWidth() == 8)
13990+
return Success(Val, E);
1399313991

1399413992
return Success(Val.byteSwap(), E);
1399513993
}

0 commit comments

Comments
 (0)