llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> We're not necessarily using an APSInt of the appropriate size from the start, so get it to the right bitwidth here. --- Full diff: https://github.com/llvm/llvm-project/pull/204516.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+2-2) - (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+2) ``````````diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 55907bf11506b..b16a34543757b 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -100,7 +100,7 @@ static void pushInteger(InterpState &S, const APSInt &Val, QualType QT) { if (T == PT_IntAPS) { unsigned BitWidth = S.getASTContext().getIntWidth(QT); auto Result = S.allocAP<IntegralAP<true>>(BitWidth); - Result.copy(Val); + Result.copy(Val.extOrTrunc(BitWidth)); S.Stk.push<IntegralAP<true>>(Result); return; } @@ -108,7 +108,7 @@ static void pushInteger(InterpState &S, const APSInt &Val, QualType QT) { if (T == PT_IntAP) { unsigned BitWidth = S.getASTContext().getIntWidth(QT); auto Result = S.allocAP<IntegralAP<false>>(BitWidth); - Result.copy(Val); + Result.copy(Val.extOrTrunc(BitWidth)); S.Stk.push<IntegralAP<false>>(Result); return; } diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 57157392f6a6e..3074a84986520 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -856,6 +856,8 @@ namespace ctz { char ctz53[__builtin_ctzg((unsigned __int128)0x10, 42) == 4 ? 1 : -1]; char ctz54[__builtin_ctzg((unsigned __int128)1 << (BITSIZE(__int128) - 1)) == BITSIZE(__int128) - 1 ? 1 : -1]; char ctz55[__builtin_ctzg((unsigned __int128)1 << (BITSIZE(__int128) - 1), 42) == BITSIZE(__int128) - 1 ? 1 : -1]; + + static_assert(__builtin_elementwise_ctzg((__int128)42) == 1, ""); #endif #ifndef __AVR__ int ctz56 = __builtin_ctzg((unsigned _BitInt(128))0); `````````` </details> https://github.com/llvm/llvm-project/pull/204516 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
