GCC modified for the FreeChainXenon project
Find a file
Xi Ruoyao c5651e9bc0
LoongArch: Fix FP vector comparsons [PR113034]
We had the following mappings between <x>vfcmp submenmonics and RTX
codes:

    (define_code_attr fcc
      [(unordered "cun")
       (ordered   "cor")
       (eq       "ceq")
       (ne       "cne")
       (uneq      "cueq")
       (unle      "cule")
       (unlt      "cult")
       (le       "cle")
       (lt       "clt")])

This is inconsistent with scalar code:

    (define_code_attr fcond [(unordered "cun")
                             (uneq "cueq")
                             (unlt "cult")
                             (unle "cule")
                             (eq "ceq")
                             (lt "slt")
                             (le "sle")
                             (ordered "cor")
                             (ltgt "sne")
                             (ne "cune")
                             (ge "sge")
                             (gt "sgt")
                             (unge "cuge")
                             (ungt "cugt")])

For every RTX code for which the LSX/LASX code is different from the
scalar code, the scalar code is correct and the LSX/LASX code is wrong.
Most seriously, the RTX code NE should be mapped to "cneq", not "cne".
Rewrite <x>vfcmp define_insns in simd.md using the same mapping as
scalar fcmp.

Note that GAS does not support [x]vfcmp.{c/s}[u]{ge/gt} (pseudo)
instruction (although fcmp.{c/s}[u]{ge/gt} is supported), so we need to
switch the order of inputs and use [x]vfcmp.{c/s}[u]{le/lt} instead.

The <x>vfcmp.{sult/sule/clt/cle}.{s/d} instructions do not have a single
RTX code, but they can be modeled as an inversed RTX code following a
"not" operation.  Doing so allows the compiler to optimized vectorized
__builtin_isless etc. to a single instruction.  This optimization should
be added for scalar code too and I'll do it later.

Tests are added for mapping between C code, IEC 60559 operations, and
vfcmp instructions.

[1]:https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640713.html

gcc/ChangeLog:

	PR target/113034
	* config/loongarch/lasx.md (UNSPEC_LASX_XVFCMP_*): Remove.
	(lasx_xvfcmp_caf_<flasxfmt>): Remove.
	(lasx_xvfcmp_cune_<FLASX:flasxfmt>): Remove.
	(FSC256_UNS): Remove.
	(fsc256): Remove.
	(lasx_xvfcmp_<vfcond:fcc>_<FLASX:flasxfmt>): Remove.
	(lasx_xvfcmp_<fsc256>_<FLASX:flasxfmt>): Remove.
	* config/loongarch/lsx.md (UNSPEC_LSX_XVFCMP_*): Remove.
	(lsx_vfcmp_caf_<flsxfmt>): Remove.
	(lsx_vfcmp_cune_<FLSX:flsxfmt>): Remove.
	(vfcond): Remove.
	(fcc): Remove.
	(FSC_UNS): Remove.
	(fsc): Remove.
	(lsx_vfcmp_<vfcond:fcc>_<FLSX:flsxfmt>): Remove.
	(lsx_vfcmp_<fsc>_<FLSX:flsxfmt>): Remove.
	* config/loongarch/simd.md
	(fcond_simd): New define_code_iterator.
	(<simd_isa>_<x>vfcmp_<fcond:fcond_simd>_<simdfmt>):
	New define_insn.
	(fcond_simd_rev): New define_code_iterator.
	(fcond_rev_asm): New define_code_attr.
	(<simd_isa>_<x>vfcmp_<fcond:fcond_simd_rev>_<simdfmt>):
	New define_insn.
	(fcond_inv): New define_code_iterator.
	(fcond_inv_rev): New define_code_iterator.
	(fcond_inv_rev_asm): New define_code_attr.
	(<simd_isa>_<x>vfcmp_<fcond_inv>_<simdfmt>): New define_insn.
	(<simd_isa>_<x>vfcmp_<fcond_inv:fcond_inv_rev>_<simdfmt>):
	New define_insn.
	(UNSPEC_SIMD_FCMP_CAF, UNSPEC_SIMD_FCMP_SAF,
	UNSPEC_SIMD_FCMP_SEQ, UNSPEC_SIMD_FCMP_SUN,
	UNSPEC_SIMD_FCMP_SUEQ, UNSPEC_SIMD_FCMP_CNE,
	UNSPEC_SIMD_FCMP_SOR, UNSPEC_SIMD_FCMP_SUNE): New unspecs.
	(SIMD_FCMP): New define_int_iterator.
	(fcond_unspec): New define_int_attr.
	(<simd_isa>_<x>vfcmp_<fcond_unspec>_<simdfmt>): New define_insn.
	* config/loongarch/loongarch.cc (loongarch_expand_lsx_cmp):
	Remove unneeded special cases.

gcc/testsuite/ChangeLog:

	PR target/113034
	* gcc.target/loongarch/vfcmp-f.c: New test.
	* gcc.target/loongarch/vfcmp-d.c: New test.
	* gcc.target/loongarch/xvfcmp-f.c: New test.
	* gcc.target/loongarch/xvfcmp-d.c: New test.
	* gcc.target/loongarch/vector/lasx/lasx-vcond-2.c: Scan for cune
	instead of cne.
	* gcc.target/loongarch/vector/lsx/lsx-vcond-2.c: Likewise.
2023-12-20 20:01:51 +08:00
.github
c++tools
config Daily bump. 2023-12-01 00:17:36 +00:00
contrib Daily bump. 2023-12-15 00:17:17 +00:00
fixincludes
gcc LoongArch: Fix FP vector comparsons [PR113034] 2023-12-20 20:01:51 +08:00
gnattools
gotools
include Daily bump. 2023-12-16 00:17:35 +00:00
INSTALL
libada
libatomic Daily bump. 2023-12-16 00:17:35 +00:00
libbacktrace Daily bump. 2023-12-01 00:17:36 +00:00
libcc1 Daily bump. 2023-12-07 00:17:06 +00:00
libcody
libcpp Daily bump. 2023-12-14 00:18:00 +00:00
libdecnumber
libffi
libgcc strub: sparc: omit frame in strub_leave [PR112917] 2023-12-20 05:18:17 -03:00
libgfortran Daily bump. 2023-12-20 00:17:48 +00:00
libgm2 Daily bump. 2023-12-14 00:18:00 +00:00
libgo libgo: update configure.ac to upstream GCC 2023-11-30 13:23:53 -08:00
libgomp Daily bump. 2023-12-19 00:17:36 +00:00
libgrust Daily bump. 2023-12-15 00:17:17 +00:00
libiberty Daily bump. 2023-12-06 00:17:50 +00:00
libitm
libobjc
libphobos Daily bump. 2023-12-19 00:17:36 +00:00
libquadmath Daily bump. 2023-12-13 00:17:49 +00:00
libsanitizer Daily bump. 2023-11-29 00:17:27 +00:00
libssp
libstdc++-v3 Daily bump. 2023-12-19 00:17:36 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2023-12-15 00:17:17 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
configure.ac build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS libgrust: Add entry for maintainers 2023-12-14 13:34:20 +01:00
Makefile.def build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
Makefile.in build: Add libgrust as compilation modules 2023-12-14 13:58:57 +01:00
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
SECURITY.txt
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.