]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: When -mfpu=none, '__loongarch_frecipe' shouldn't be defined [PR118843].
authorLulu Cheng <chenglulu@loongson.cn>
Wed, 12 Feb 2025 03:50:50 +0000 (11:50 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Fri, 14 Feb 2025 07:48:45 +0000 (15:48 +0800)
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.

gcc/config/loongarch/loongarch-c.cc
gcc/testsuite/gcc.target/loongarch/pr118843.c [new file with mode: 0644]

index 66ae77ad665f304145f2208f48813f5c9835a90b..effdcf0e25544d9f5e6511f8fabcc50f366a9dcb 100644 (file)
@@ -129,9 +129,6 @@ loongarch_update_cpp_builtins (cpp_reader *pfile)
   else
     builtin_define ("__loongarch_frlen=0");
 
-  loongarch_def_or_undef (TARGET_HARD_FLOAT && ISA_HAS_FRECIPE,
-                         "__loongarch_frecipe", pfile);
-
   loongarch_def_or_undef (ISA_HAS_LSX, "__loongarch_simd", pfile);
   loongarch_def_or_undef (ISA_HAS_LSX, "__loongarch_sx", pfile);
   loongarch_def_or_undef (ISA_HAS_LASX, "__loongarch_asx", pfile);
@@ -149,17 +146,23 @@ loongarch_update_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])
-      {
-       builtin_define (la_evo_macro_name[i]);
+    {
+      builtin_undef (la_evo_macro_name[i]);
 
-       int major = la_evo_version_major[i],
-           minor = la_evo_version_minor[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]);
 
-       max_v_major = major > max_v_major ? major : max_v_major;
-       max_v_minor = major == max_v_major
-         ? (minor > max_v_minor ? minor : max_v_minor) : max_v_minor;
-      }
+         int major = la_evo_version_major[i],
+         minor = la_evo_version_minor[i];
+
+         max_v_major = major > max_v_major ? major : max_v_major;
+         max_v_minor = major == max_v_major
+           ? (minor > max_v_minor ? minor : max_v_minor) : max_v_minor;
+       }
+    }
 
   /* Find the minimum ISA version required to run the target program.  */
   builtin_undef ("__loongarch_version_major");
diff --git a/gcc/testsuite/gcc.target/loongarch/pr118843.c b/gcc/testsuite/gcc.target/loongarch/pr118843.c
new file mode 100644 (file)
index 0000000..30372b8
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do preprocess } */
+/* { dg-options "-mfrecipe -mfpu=none" } */
+
+#ifdef __loongarch_frecipe
+#error __loongarch_frecipe should not be avaliable here
+#endif