]> 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>
Mon, 17 Feb 2025 06:55:19 +0000 (14:55 +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.

(cherry picked from commit ee579b7c257468b9032ab4583ec455fa871d4428)

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

index c6763647cd13ab9af32b9d5b4b37d55667461349..591d1dabcdf949782ace3653fdfbf961746bef5a 100644 (file)
@@ -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 (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