Many thanks to Richard Biener for approving the midde-end patch that cleared the way for this one. This nvptx patch defines the target hook TARGET_TRULY_NOOP_TRUNCATION to false, indicating that integer truncations require explicit instructions. nvptx.c already defines TARGET_MODES_TIEABLE_P and TARGET_CAN_CHANGE_MODE_CLASS to false, and as (previously) documented that may require TARGET_TRULY_NOOP_TRUNCATION to be defined likewise.
This patch decreases the number of unexpected failures in the testsuite by 10, and increases the number of expected passes by 4, including these previous FAILs/ICEs: gcc.c-torture/compile/opout.c gcc.dg/torture/pr79125.c gcc.dg/tree-ssa/pr92085-1.c Unfortunately there is one testsuite failure that used to pass gcc.target/nvptx/v2si-cvt.c, but this isn't an ICE or incorrect code. As explained in this test, the scan-assembler already isn't testing what it should. Given that there are several (nvptx) patches pending review that affect code generation of this example, and (perhaps) more on the way, I propose letting this test FAIL for now until the dust settles and it becomes clear what instruction(s) should be generated (certainly not a cvt.u32.u32). This patch has been tested on nvptx-none hosted on x86_64-pc-linux-gnu with "make" and "make check" with fewer ICEs and no wrong code regressions. Ok for mainline? 2020-07-16 Roger Sayle <ro...@nextmovesoftware.com> gcc/ChangeLog * config/nvptx/nvptx.c (nvptx_truly_noop_truncation): Implement. (TARGET_TRULY_NOOP_TRUNCATION): Define. Thanks in advance. -- Roger Sayle NextMove Software Cambridge, UK
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index e3e84df..f5b5d8c 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -6450,6 +6450,14 @@ nvptx_can_change_mode_class (machine_mode, machine_mode, reg_class_t) return false; } +/* Implement TARGET_TRULY_NOOP_TRUNCATION. */ + +static bool +nvptx_truly_noop_truncation (poly_uint64, poly_uint64) +{ + return false; +} + static GTY(()) tree nvptx_previous_fndecl; static void @@ -6599,6 +6607,9 @@ nvptx_set_current_function (tree fndecl) #undef TARGET_CAN_CHANGE_MODE_CLASS #define TARGET_CAN_CHANGE_MODE_CLASS nvptx_can_change_mode_class +#undef TARGET_TRULY_NOOP_TRUNCATION +#define TARGET_TRULY_NOOP_TRUNCATION nvptx_truly_noop_truncation + #undef TARGET_HAVE_SPECULATION_SAFE_VALUE #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed