[Committed] Fix subreg_promoted_mode breakage on various platforms.

My apologies for the inconvenience.  My recent patch to preserve
SUBREG_PROMOTED_VAR_P on (extend:HI (subreg/s:QI (reg:SI))), and other
places in the middle-end, has broken the build on several targets.

The change to convert_modes inadvertently used the same
subreg_promoted_mode idiom for retrieving the mode of a SUBREG_REG
as the existing code just a few lines earlier.  Alas in the meantime,
the original SUBREG gets replaced by one without SUBREG_PROMOTED_VAR_P,
the whole raison-d'etre for my patch, and I'd not realized/noticed
that subreg_promoted_mode asserts for this.  Alas neither the bootstrap
and regression test on x86_64-pc-linux-gnu nor my testing on nvptx-none
must have hit this particular case.  The logic of this transformation
is sound, it's the implementation that's bitten me.

This patch has been committed, after another "make bootstrap" on
x86_64-pc-linux-gnu (just in case), and confirmation/pre-approval
from Jeff Law that this indeed fixes the build failures seen on
several platforms.

My humble apologies again.

2021-08-31  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* expr.c (convert_modes): Don't use subreg_promoted_mode on a
	SUBREG if it can't be guaranteed to a SUBREG_PROMOTED_VAR_P set.
	Instead use the standard (safer) is_a <scalar_int_mode> idiom.
This commit is contained in:
Roger Sayle 2021-08-31 17:25:58 +01:00
parent 17dc903ed3
commit 863d6524f3
1 changed files with 6 additions and 3 deletions

View File

@ -690,17 +690,20 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp)
&& SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp))
{
scalar_int_mode int_orig_mode;
scalar_int_mode int_inner_mode;
machine_mode orig_mode = GET_MODE (x);
x = gen_lowpart (int_mode, SUBREG_REG (x));
/* Preserve SUBREG_PROMOTED_VAR_P if the new mode is wider than
the original mode, but narrower than the inner mode. */
if (GET_CODE (x) == SUBREG
&& GET_MODE_PRECISION (subreg_promoted_mode (x))
> GET_MODE_PRECISION (int_mode)
&& is_a <scalar_int_mode> (orig_mode, &int_orig_mode)
&& GET_MODE_PRECISION (int_mode)
> GET_MODE_PRECISION (int_orig_mode))
> GET_MODE_PRECISION (int_orig_mode)
&& is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)),
&int_inner_mode)
&& GET_MODE_PRECISION (int_inner_mode)
> GET_MODE_PRECISION (int_mode))
{
SUBREG_PROMOTED_VAR_P (x) = 1;
SUBREG_PROMOTED_SET (x, unsignedp);