]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
C-SKY: Fix expanding of float LE comparing with zero for fpuv3.
authorXianmiao Qu <cooper.qu@linux.alibaba.com>
Wed, 7 Sep 2022 09:19:54 +0000 (17:19 +0800)
committerXianmiao Qu <cooper.qu@linux.alibaba.com>
Wed, 7 Sep 2022 11:03:10 +0000 (19:03 +0800)
The original code will cause the warning:
/usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o csky.o -MT csky.o -MMD -MP -MF ./.deps/csky.TPo ../../gcc/gcc/config/csky/csky.cc
In file included from ../../gcc/gcc/config/csky/csky.h:183,
                from ./tm.h:20,
                from ../../gcc/gcc/backend.h:28,
                from ../../gcc/gcc/config/csky/csky.cc:27:
../../gcc/gcc/config/csky/csky.cc: In function 'bool csky_emit_compare_float(rtx_code, rtx, rtx)':
../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context]
  29 | #define CSKY_ISA_FEATURE_DEFINE(x)  isa_bit_ ## x
      |                                     ^~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE'
  30 | #define CSKY_ISA_FEATURE_GET(x)     CSKY_ISA_FEATURE_DEFINE (x)
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET'
6346 |                                        || CSKY_ISA_FEATURE_GET(fpv2_df)
      |                                           ^~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context]
  29 | #define CSKY_ISA_FEATURE_DEFINE(x)  isa_bit_ ## x
      |                                     ^~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE'
  30 | #define CSKY_ISA_FEATURE_GET(x)     CSKY_ISA_FEATURE_DEFINE (x)
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET'
6346 |                                        || CSKY_ISA_FEATURE_GET(fpv2_df)
      |                                           ^~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context]
  29 | #define CSKY_ISA_FEATURE_DEFINE(x)  isa_bit_ ## x
      |                                     ^~~~~~~~
../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE'
  30 | #define CSKY_ISA_FEATURE_GET(x)     CSKY_ISA_FEATURE_DEFINE (x)
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/csky/csky.cc:6347:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET'
6347 |                                        || CSKY_ISA_FEATURE_GET(fpv2_divd)))
      |                                           ^~~~~~~~~~~~~~~~~~~~

The 'CSKY_ISA_FEATURE_DEFINE (x)' is an enum contant, it will cause the condition always being true.
In addition to warning, it will let FPUV3 to generate a move instruction, which is unnecessary.
In a simple test case, the move instruction can be combined, so it was not found in the testsuite.
But in some complex scenarios, this may generate some redundant instructions.
The correct way is to use 'CSKY_ISA_FEATURE' instead of 'CSKY_ISA_FEATURE_DEFINE'.

gcc/
* config/csky/csky.cc (csky_emit_compare_float): Fix the expanding of
float LE comparing with zero for fpuv3.
* config/csky/csky.h (TARGET_SUPPORT_FPV2): New, true if any fpuv2
features are enabled.

gcc/config/csky/csky.cc
gcc/config/csky/csky.h

index a7dc6cefeadb4990f51f8f45b643d35987ec19fe..4dc74d8924f6a86b318c626e228e3590a753b8cc 100644 (file)
@@ -6342,9 +6342,7 @@ csky_emit_compare_float (enum rtx_code code, rtx op0, rtx op1)
     case GT:
     case LT:
     case LE:
-      if (op1 == CONST0_RTX (mode) && (CSKY_ISA_FEATURE_GET(fpv2_sf)
-                                      || CSKY_ISA_FEATURE_GET(fpv2_df)
-                                      || CSKY_ISA_FEATURE_GET(fpv2_divd)))
+      if (op1 == CONST0_RTX (mode) && TARGET_SUPPORT_FPV2)
        op1 = force_reg (mode, op1);
       break;
     case ORDERED:
index 37410f0cda49644491130ac8112c8a72927744e4..f786ad55d43f1ea349accb86241acdaff8a45c8b 100644 (file)
                             || CSKY_ISA_FEATURE (fpv3_sf) \
                             || CSKY_ISA_FEATURE (fpv3_df))
 
+#define TARGET_SUPPORT_FPV2 (CSKY_ISA_FEATURE(fpv2_sf)    \
+                            || CSKY_ISA_FEATURE(fpv2_df) \
+                            || CSKY_ISA_FEATURE(fpv2_divd))
+
 /* Number of loads/stores handled by ldm/stm.  */
 #define CSKY_MIN_MULTIPLE_STLD 3
 #define CSKY_MAX_MULTIPLE_STLD 12