Hi Richard, > It seems to be improving TARGET_TRULY_NOOP_TRUNCATION documentation might be > useful here.
This is an excellent suggestion. How about the following/attached: 2020-07-13 Roger Sayle <ro...@nextmovesoftware.com> gcc/ChangeLog: * doc/tm.texi (TARGET_TRULY_NOOP_TRUNCATION): Clarify that targets that (sometimes) return false, indicating SUBREGs shouldn't be used, also need to provide a trunc?i?i2 optab that performs this truncation. > The only user (after your patch) of this hook is in function.c for the > function parameter setup btw. The targetm.truly_noop_truncation in assign_parm_setup_block is the last place that calls this hook directly (with sizes), but the majority of uses go via TRULY_NOOP_TRUNCATION_MODES_P as defined in machmode.h. I'll prepare a patch to switch function.c to use TRULY_NOOP_TRUNCATION_MODE_P so that we are consistent throughout the compiler. In theory, this hook could then be changed to take modes instead of (poly_unit64) sizes, but that clean-up might be tricky without access to the affected platforms. The hard register semantics that you're referring to are related to TARGET_MODES_TIEABLE_P, which is documented to have interesting interactions with TARGET_TRULY_NOOP_TRUNCATION. Is the above documentation change Ok for mainline? Thanks, Roger --
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 6e7d9dc54a9..41b9e10c856 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11122,7 +11122,9 @@ This hook returns true if it is safe to ``convert'' a value of @var{inprec} bits to one of @var{outprec} bits (where @var{outprec} is smaller than @var{inprec}) by merely operating on it as if it had only @var{outprec} bits. The default returns true unconditionally, which -is correct for most machines. +is correct for most machines. When @code{TARGET_TRULY_NOOP_TRUNCATION} +returns false, the machine description should provide a @code{trunc} +optab to specify the RTL that performs the required truncation. If @code{TARGET_MODES_TIEABLE_P} returns false for a pair of modes, suboptimal code can result if this hook returns true for the corresponding