gcc/gcc/testsuite/lib
Philipp Tomsich af039edf70 RISC-V: Implement C[LT]Z_DEFINED_VALUE_AT_ZERO
The Zbb support has introduced ctz and clz to the backend, but some
transformations in GCC need to know what the value of c[lt]z at zero
is. This affects how the optab is generated and may suppress use of
CLZ/CTZ in tree passes.

Among other things, this is needed for the transformation of
table-based ctz-implementations, such as in deepsjeng, to work
(see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838).

Prior to this change, the test case from PR90838 would compile to
on RISC-V targets with Zbb:
  myctz:
	lui	a4,%hi(.LC0)
	ld	a4,%lo(.LC0)(a4)
	neg	a5,a0
	and	a5,a5,a0
	mul	a5,a5,a4
	lui	a4,%hi(.LANCHOR0)
	addi	a4,a4,%lo(.LANCHOR0)
	srli	a5,a5,58
	sh2add	a5,a5,a4
	lw	a0,0(a5)
	ret

After this change, we get:
  myctz:
	ctz	a0,a0
	andi	a0,a0,63
	ret

Testing this with deepsjeng_r (from SPEC 2017) against QEMU, this
shows a clear reduction in dynamic instruction count:
 - before  1961888067076
 - after   1907928279874 (2.75% reduction)

This also merges the various target-specific test-cases (for x86-64,
aarch64 and riscv) within gcc.dg/pr90838.c.

This extends the macros (i.e., effective-target keywords) used in
testing (lib/target-supports.exp) to reliably distinguish between RV32
and RV64 via __riscv_xlen (i.e., the integer register bitwidth) :
testing for ILP32 could be misleading (as ILP32 is a valid memory
model for 64bit systems).

gcc/ChangeLog:

	* config/riscv/riscv.h (CLZ_DEFINED_VALUE_AT_ZERO): Implement.
	(CTZ_DEFINED_VALUE_AT_ZERO): Same.
	* doc/sourcebuild.texi: add documentation for RISC-V specific
	test target keywords

gcc/testsuite/ChangeLog:

	* gcc.dg/pr90838.c: Add additional flags (dg-additional-options)
	  when compiling for riscv64 and subsume gcc.target/aarch64/pr90838.c
	  and gcc.target/i386/pr95863-2.c.
	* gcc.target/aarch64/pr90838.c: Removed.
	* gcc.target/i386/pr95863-2.c: Removed.
	* lib/target-supports.exp: Recognize RV32 or RV64 via XLEN

Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Signed-off-by: Manolis Tsamis <manolis.tsamis@vrull.eu>
Co-authored-by: Manolis Tsamis <manolis.tsamis@vrull.eu>

(cherry picked from commit 16f7fcadac)
2022-06-02 21:03:36 +02:00
..
asan-dg.exp
atomic-dg.exp
c-compat.exp
c-torture.exp
clearcap.exp
compat.exp
copy-file.exp
dejapatches.exp
dg-pch.exp
file-format.exp
fortran-modules.exp
fortran-torture.exp
g++-dg.exp testsuite: Allow setting gpp_std_list in configuration files 2022-03-29 20:30:44 +01:00
g++.exp testsuite: Allow setting gpp_std_list in configuration files 2022-03-29 20:30:44 +01:00
gcc-defs.exp
gcc-dg.exp
gcc-gdb-test.exp
gcc-simulate-thread.exp
gcc.exp
gcov.exp
gdc-dg.exp
gdc-utils.exp
gdc.exp
gfortran-dg.exp
gfortran.exp
gnat-dg.exp
gnat.exp
go-dg.exp
go-torture.exp
go.exp
hwasan-dg.exp
lto.exp
mike-g++.exp
mike-gcc.exp
multiline.exp
obj-c++-dg.exp
obj-c++.exp
objc-dg.exp
objc-torture.exp
objc.exp
options.exp
plugin-support.exp
profopt.exp
prune.exp [committed] Fix more problems with new linker warnings 2022-04-28 12:09:00 -04:00
scanasm.exp
scandump.exp
scanipa.exp
scanlang.exp
scanltranstree.exp
scanoffload.exp
scanoffloadrtl.exp
scanoffloadtree.exp
scanrtl.exp
scantree.exp
scanwpaipa.exp
target-libpath.exp
target-supports-dg.exp
target-supports.exp RISC-V: Implement C[LT]Z_DEFINED_VALUE_AT_ZERO 2022-06-02 21:03:36 +02:00
target-utils.exp
timeout-dg.exp
timeout.exp
torture-options.exp
tsan-dg.exp
ubsan-dg.exp
wrapper.exp