Consider this code:
typedef float float3 __attribute__((ext_vector_type(3)));
typedef struct {
float3 b;
} struct_float3;
float3 foo(float3 a, const struct_float3* hi) {
return __builtin_elementwise_fma(a, a, hi->b.yyy);
}
float3 bar(float3 a, const struct_float3* hi) {
return __builtin_elementwise_pow(a, hi->b.yyy);
}
Clang will report an error about foo but not bar:
source.cpp:19:36: error: arguments are of different types ('float3' (vector of 3 'float' values) vs 'const float3' (vector of 3 'float' values))
19 | return __builtin_elementwise_fma(a, a, hi->b.yyy);
| ^
The solution is to use ASTContext::hasSameUnqualifiedType() in BuiltinElementwiseTernaryMath similar to #141397. This was originally discovered by @tbaederr in #153572 (comment).