Skip to content

Commit 0a36c43

Browse files
author
liuzhenya
committed
fix: minors
1 parent c9ff54c commit 0a36c43

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,27 +2419,6 @@ static bool interp__builtin_elementwise_int_unaryop(
24192419
return false;
24202420
}
24212421

2422-
static bool interp__builtin_select_scalar(InterpState &S,
2423-
const CallExpr *Call) {
2424-
unsigned N =
2425-
Call->getArg(1)->getType()->getAs<VectorType>()->getNumElements();
2426-
2427-
const Pointer &W = S.Stk.pop<Pointer>();
2428-
const Pointer &A = S.Stk.pop<Pointer>();
2429-
APSInt U = popToAPSInt(S, Call->getArg(0));
2430-
const Pointer &Dst = S.Stk.peek<Pointer>();
2431-
2432-
bool TakeA0 = U.getZExtValue() & 1ULL;
2433-
2434-
for (unsigned I = TakeA0; I != N; ++I)
2435-
Dst.elem<Floating>(I) = W.elem<Floating>(I);
2436-
if (TakeA0)
2437-
Dst.elem<Floating>(0) = A.elem<Floating>(0);
2438-
2439-
Dst.initializeAllElements();
2440-
return true;
2441-
}
2442-
24432422
static bool interp__builtin_elementwise_int_binop(
24442423
InterpState &S, CodePtr OpPC, const CallExpr *Call,
24452424
llvm::function_ref<APInt(const APSInt &, const APSInt &)> Fn) {
@@ -2829,6 +2808,30 @@ static bool interp__builtin_select(InterpState &S, CodePtr OpPC,
28292808
return true;
28302809
}
28312810

2811+
/// Scalar variant of AVX512 predicated select:
2812+
/// Result[i] = (Mask bit 0) ? LHS[i] : RHS[i], but only element 0 may change.
2813+
/// All other elements are taken from RHS.
2814+
static bool interp__builtin_select_scalar(InterpState &S,
2815+
const CallExpr *Call) {
2816+
unsigned N =
2817+
Call->getArg(1)->getType()->getAs<VectorType>()->getNumElements();
2818+
2819+
const Pointer &W = S.Stk.pop<Pointer>();
2820+
const Pointer &A = S.Stk.pop<Pointer>();
2821+
APSInt U = popToAPSInt(S, Call->getArg(0));
2822+
const Pointer &Dst = S.Stk.peek<Pointer>();
2823+
2824+
bool TakeA0 = U.getZExtValue() & 1ULL;
2825+
2826+
for (unsigned I = TakeA0; I != N; ++I)
2827+
Dst.elem<Floating>(I) = W.elem<Floating>(I);
2828+
if (TakeA0)
2829+
Dst.elem<Floating>(0) = A.elem<Floating>(0);
2830+
2831+
Dst.initializeAllElements();
2832+
return true;
2833+
}
2834+
28322835
static bool interp__builtin_blend(InterpState &S, CodePtr OpPC,
28332836
const CallExpr *Call) {
28342837
APSInt Mask = popToAPSInt(S, Call->getArg(2));

clang/lib/AST/ExprConstant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12214,8 +12214,8 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1221412214
SmallVector<APValue, 4> Res;
1221512215
Res.reserve(Len);
1221612216
Res.push_back(TakeA0 ? AVal.getVectorElt(0) : WVal.getVectorElt(0));
12217-
for (unsigned i = 1; i < Len; ++i)
12218-
Res.push_back(WVal.getVectorElt(i));
12217+
for (unsigned I = 1; I < Len; ++I)
12218+
Res.push_back(WVal.getVectorElt(I));
1221912219
APValue V(Res.data(), Res.size());
1222012220
return Success(V, E);
1222112221
};

0 commit comments

Comments
 (0)