https://gcc.gnu.org/g:889fb66025cef4e434cc60e35add9f7406e38db7

commit r14-11316-g889fb66025cef4e434cc60e35add9f7406e38db7
Author: Lulu Cheng <chengl...@loongson.cn>
Date:   Wed Feb 12 11:50:50 2025 +0800

    LoongArch: When -mfpu=none, '__loongarch_frecipe' shouldn't be defined 
[PR118843].
    
            PR target/118843
    
    gcc/ChangeLog:
    
            * config/loongarch/loongarch-c.cc
            (loongarch_update_cpp_builtins): Fix macro definition issues.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/loongarch/pr118843.c: New test.
    
    (cherry picked from commit ee579b7c257468b9032ab4583ec455fa871d4428)

Diff:
---
 gcc/config/loongarch/loongarch-c.cc           | 7 +++----
 gcc/testsuite/gcc.target/loongarch/pr118843.c | 6 ++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gcc/config/loongarch/loongarch-c.cc 
b/gcc/config/loongarch/loongarch-c.cc
index c6763647cd13..591d1dabcdf9 100644
--- a/gcc/config/loongarch/loongarch-c.cc
+++ b/gcc/config/loongarch/loongarch-c.cc
@@ -85,9 +85,6 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile)
   else
     builtin_define ("__loongarch_frlen=0");
 
-  if (TARGET_HARD_FLOAT && ISA_HAS_FRECIPE)
-    builtin_define ("__loongarch_frecipe");
-
   if (ISA_HAS_LSX)
     {
       builtin_define ("__loongarch_simd");
@@ -107,7 +104,9 @@ loongarch_cpu_cpp_builtins (cpp_reader *pfile)
   int max_v_major = 1, max_v_minor = 0;
 
   for (int i = 0; i < N_EVO_FEATURES; i++)
-    if (la_target.isa.evolution & la_evo_feature_masks[i])
+    if (la_target.isa.evolution & la_evo_feature_masks[i]
+       && (la_evo_feature_masks[i] != OPTION_MASK_ISA_FRECIPE
+           || TARGET_HARD_FLOAT))
       {
        builtin_define (la_evo_macro_name[i]);
 
diff --git a/gcc/testsuite/gcc.target/loongarch/pr118843.c 
b/gcc/testsuite/gcc.target/loongarch/pr118843.c
new file mode 100644
index 000000000000..30372b8ffe6a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/pr118843.c
@@ -0,0 +1,6 @@
+/* { dg-do preprocess } */
+/* { dg-options "-mfrecipe -mfpu=none" } */
+
+#ifdef __loongarch_frecipe
+#error __loongarch_frecipe should not be avaliable here
+#endif

Reply via email to