[clang] [clang] constexpr built-in elementwise bitreverse function. (PR #118177)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 2 03:05:47 PST 2024
================
@@ -11322,9 +11323,19 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
for (unsigned EltNum = 0; EltNum < SourceLen; ++EltNum) {
APSInt Elt = Source.getVectorElt(EltNum).getInt();
- ResultElements.push_back(
- APValue(APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), Elt.popcount()),
- DestEltTy->isUnsignedIntegerOrEnumerationType())));
+ switch (E->getBuiltinCallee()) {
+ case Builtin::BI__builtin_elementwise_popcount:
+ ResultElements.push_back(APValue(
+ APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), Elt.popcount()),
+ DestEltTy->isUnsignedIntegerOrEnumerationType())));
+ break;
+ case Builtin::BI__builtin_elementwise_bitreverse:
+ ResultElements.push_back(
+ APValue(APSInt(Elt.reverseBits(),
+ DestEltTy->isUnsignedIntegerOrEnumerationType())
+ .extOrTrunc(Info.Ctx.getIntWidth(DestEltTy))));
----------------
RKSimon wrote:
why do you need the extOrTrunc? Shouldn't the src/dst types be equal?
https://github.com/llvm/llvm-project/pull/118177
More information about the cfe-commits
mailing list