[clang] [Headers][X86] Allow SLLDQ/SRLDQ byte shift intrinsics to be used in constexpr (PR #164166)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 22 01:06:39 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions c,cpp -- clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/lib/AST/ExprConstant.cpp clang/test/CodeGen/X86/avx2-builtins.c clang/test/CodeGen/X86/sse2-builtins.c --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 54b38d267..8012a1fe0 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -3279,10 +3279,11 @@ static bool interp__builtin_ia32_vpconflict(InterpState &S, CodePtr OpPC,
return true;
}
-static bool interp__builtin_x86_byteshift(InterpState &S, CodePtr OpPC,
- const CallExpr *Call,
- unsigned ID,
- llvm::function_ref<APInt(const Pointer &, PrimType ElemT, unsigned Lane, unsigned I, unsigned Shift)> Fn) {
+static bool interp__builtin_x86_byteshift(
+ InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID,
+ llvm::function_ref<APInt(const Pointer &, PrimType ElemT, unsigned Lane,
+ unsigned I, unsigned Shift)>
+ Fn) {
assert(Call->getNumArgs() == 2);
APSInt ImmAPS = popToAPSInt(S, Call->getArg(1));
@@ -3300,7 +3301,8 @@ static bool interp__builtin_x86_byteshift(InterpState &S, CodePtr OpPC,
for (unsigned I = 0; I != 16; ++I) {
unsigned Base = Lane + I;
APSInt Result = APSInt(Fn(Src, ElemT, Lane, I, Shift));
- INT_TYPE_SWITCH_NO_BOOL(ElemT, {Dst.elem<T>(Base) = static_cast<T>(Result);});
+ INT_TYPE_SWITCH_NO_BOOL(ElemT,
+ { Dst.elem<T>(Base) = static_cast<T>(Result); });
}
}
@@ -4363,31 +4365,39 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
case X86::BI__builtin_ia32_pslldqi128_byteshift:
case X86::BI__builtin_ia32_pslldqi256_byteshift:
- return interp__builtin_x86_byteshift(S, OpPC, Call, BuiltinID, [](const Pointer &Src, PrimType ElemT, unsigned Lane, unsigned I, unsigned Shift) {
- APInt v;
- INT_TYPE_SWITCH_NO_BOOL(ElemT, {
- if(I < Shift) {
- v = APInt(sizeof(T) * 8, 0);
- } else {
- v = APInt(sizeof(T) * 8, static_cast<uint64_t>(Src.elem<T>(Lane + I - Shift)));
- }
- });
- return v;
- });
+ return interp__builtin_x86_byteshift(
+ S, OpPC, Call, BuiltinID,
+ [](const Pointer &Src, PrimType ElemT, unsigned Lane, unsigned I,
+ unsigned Shift) {
+ APInt v;
+ INT_TYPE_SWITCH_NO_BOOL(ElemT, {
+ if (I < Shift) {
+ v = APInt(sizeof(T) * 8, 0);
+ } else {
+ v = APInt(sizeof(T) * 8,
+ static_cast<uint64_t>(Src.elem<T>(Lane + I - Shift)));
+ }
+ });
+ return v;
+ });
case X86::BI__builtin_ia32_psrldqi128_byteshift:
case X86::BI__builtin_ia32_psrldqi256_byteshift:
- return interp__builtin_x86_byteshift(S, OpPC, Call, BuiltinID, [](const Pointer &Src, PrimType ElemT, unsigned Lane, unsigned I, unsigned Shift) {
- APInt v;
- INT_TYPE_SWITCH_NO_BOOL(ElemT, {
- if(I + Shift < 16) {
- v = APInt(sizeof(T) * 8, static_cast<uint64_t>(Src.elem<T>(Lane + I + Shift)));
- } else {
- v = APInt(sizeof(T) * 8, 0);
- }
- });
- return v;
- });
+ return interp__builtin_x86_byteshift(
+ S, OpPC, Call, BuiltinID,
+ [](const Pointer &Src, PrimType ElemT, unsigned Lane, unsigned I,
+ unsigned Shift) {
+ APInt v;
+ INT_TYPE_SWITCH_NO_BOOL(ElemT, {
+ if (I + Shift < 16) {
+ v = APInt(sizeof(T) * 8,
+ static_cast<uint64_t>(Src.elem<T>(Lane + I + Shift)));
+ } else {
+ v = APInt(sizeof(T) * 8, 0);
+ }
+ });
+ return v;
+ });
default:
S.FFDiag(S.Current->getLocation(OpPC),
``````````
</details>
https://github.com/llvm/llvm-project/pull/164166
More information about the cfe-commits
mailing list