[PATCH] D98895: [X86][Draft] Disable long double type for -mno-x87 option

Pengfei Wang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 19 19:13:03 PDT 2021


pengfei added inline comments.


================
Comment at: clang/test/Sema/x86-no-x87.c:48-61
+void assign2() {
+  struct st_long_double st;
+#ifndef NOERROR
+  // expected-error at +2{{long double is not supported on this target}}
+#endif
+  st.ld = 0.42;
+}
----------------
asavonic wrote:
> pengfei wrote:
> > These seems pass with GCC. https://godbolt.org/z/qM4nWhThx
> Right. Assignment of a literal is compiled to just `mov` without any x87 instructions, so it is not diagnosed by GCC. On the other hand, assignment of a variable does trigger the error:
> 
>     void assign4(double d) {
>       struct st_long_double st;
>       st.ld = d; // error: long double is not supported on this target
>     }
> 
> We can update the patch to do the same for some cases, but it does not look very consistent, and makes assumptions on how the code is optimized and compiled.
> 
> GCC has an advantage here, because it emits the diagnostic at a lower level after at lease some optimizations are done. For example, the following code does not trigger an error for GCC because of inlining:
> 
>     double get_const() {
>       return 0.42;
>     }
>     void assign5(struct st_long_double *st) {
>       st->ld = get_const();
>     }
> 
I see. Another concern is about the 32 bits. @LiuChen3 had tested in D100091 that GCC doesn't error for 32 bits. Do we need to consider it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98895



More information about the cfe-commits mailing list