[PATCH] D140992: clang: Add __builtin_elementwise_fma

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 23 08:31:12 PST 2023


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: clang/lib/Sema/SemaChecking.cpp:17761-17766
+  for (int I = 0; I < 3; ++I) {
+    ExprResult Converted = UsualUnaryConversions(TheCall->getArg(I));
+    if (Converted.isInvalid())
+      return true;
+    Args[I] = Converted.get();
+  }
----------------
arsenm wrote:
> aaron.ballman wrote:
> > This will cause conversions to happen *before* we check whether the types are the same; is that expected? e.g., it seems like this would allow you to pass a float and a double and thanks to the magic of usual unary conversions they both come out as double and thus don't get diagnosed.
> The tests say that isn't happening, e.g. here:
> 
> 
> ```
> 
>   f32 = __builtin_elementwise_fma(f64, f32, f32);
>   // expected-error at -1 {{arguments are of different types ('double' vs 'float')}}
> 
>   f32 = __builtin_elementwise_fma(f32, f64, f32);
>   // expected-error at -1 {{arguments are of different types ('float' vs 'double')}}
> 
> ```
Oh, excellent, thank you!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140992/new/

https://reviews.llvm.org/D140992



More information about the cfe-commits mailing list