[all-commits] [llvm/llvm-project] 1ac366: [clang] Restrict the use of scalar types in vector...
Fraser Cormack via All-commits
all-commits at lists.llvm.org
Wed Jan 29 01:40:26 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1ac3665e66c7ddb20ef26bc275ad005186ab09fb
https://github.com/llvm/llvm-project/commit/1ac3665e66c7ddb20ef26bc275ad005186ab09fb
Author: Fraser Cormack <fraser at codeplay.com>
Date: 2025-01-29 (Wed, 29 Jan 2025)
Changed paths:
M clang/docs/LanguageExtensions.rst
M clang/include/clang/Sema/Sema.h
M clang/lib/Sema/SemaChecking.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/test/CodeGen/builtins-elementwise-math.c
M clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
M clang/test/CodeGenHLSL/implicit-norecurse-attrib.hlsl
M clang/test/Sema/builtins-elementwise-math.c
M clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl
Log Message:
-----------
[clang] Restrict the use of scalar types in vector builtins (#119423)
This commit restricts the use of scalar types in vector math builtins,
particularly the `__builtin_elementwise_*` builtins.
Previously, small scalar integer types would be promoted to `int`, as
per the usual conversions. This would silently do the wrong thing for
certain operations, such as `add_sat`, `popcount`, `bitreverse`, and
others. Similarly, since unsigned integer types were promoted to `int`,
something like `add_sat(unsigned char, unsigned char)` would perform a
*signed* operation.
With this patch, promotable scalar integer types are not promoted to
int, and are kept intact. If any of the types differ in the binary and
ternary builtins, an error is issued. Similarly an error is issued if
builtins are supplied integer types of different signs. Mixing enums of
different types in binary/ternary builtins now consistently raises an
error in all language modes.
This brings the behaviour surrounding scalar types more in line with
that of vector types. No change is made to vector types, which are both
not promoted and whose element types must match.
Fixes #84047.
RFC:
https://discourse.llvm.org/t/rfc-change-behaviour-of-elementwise-builtins-on-scalar-integer-types/83725
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list