[clang] [Clang] Enable constexpr handling for builtin elementwise fshl/fshr (PR #153572)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 25 10:21:28 PDT 2025


================
@@ -961,3 +961,51 @@ static_assert(fmaDouble1[3] == 26.0);
 constexpr float fmaArray[] = {2.0f, 2.0f, 2.0f, 2.0f};
 constexpr float fmaResult = __builtin_elementwise_fma(fmaArray[1], fmaArray[2], fmaArray[3]);
 static_assert(fmaResult == 6.0f, "");
+
+static_assert(__builtin_elementwise_fshl((unsigned char)255, (unsigned char)0, (unsigned char)8) == (unsigned char)255);
----------------
shafik wrote:

Apologies, I was looking at the documentation and it was not obvious to me: https://clang.llvm.org/docs/LanguageExtensions.html

As opposed to `__builtin_elementwise_add_sat` which specifically say results are clamped. Maybe I am being dense and not interpreting the documentation correctly. 

https://github.com/llvm/llvm-project/pull/153572


More information about the cfe-commits mailing list