[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)
Fraser Cormack via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 02:55:31 PST 2025
================
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) {
_2, _3, _4));
}
+static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) {
+ // Don't promote integer types
+ if (QualType Ty = E->getType(); S.getASTContext().isPromotableIntegerType(Ty))
+ return S.DefaultFunctionArrayLvalueConversion(E);
+ return S.UsualUnaryConversions(E);
----------------
frasercrmck wrote:
Yep, makes sense. I've added `Sema::UsualUnaryFPConversions` and am using that where appropriate. I didn't want to fold in the use of `DefaultFunctionArrayLvalueConversion` into that even though that would have saved a bit of duplicated code.
Regarding bitfields: with the current version of this patch (i.e., without the implicit promotion) we are calling the builtin according to the type you specify in the bitfield:
``` c
struct StructWithBitfield {
int i : 4;
char c: 4;
short s : 4;
};
```
`__builtin_elementwise_abs(s.i)` calls `llvm.abs.i32`, `s.c` calls `llvm.abs.i8`, `s.s` `llvm.abs.i16`, etc. I wonder if this is consistent enough behaviour to permit them?
https://github.com/llvm/llvm-project/pull/119423
More information about the cfe-commits
mailing list