From: Richard Sandiford Date: Fri, 13 Oct 2017 09:58:23 +0000 (+0000) Subject: Prevent invalid register mode changes in combine X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8649149a3cdf939cf5d74da35eae6eb4802f9cd8;p=gcc.git Prevent invalid register mode changes in combine This patch stops combine from changing the mode of an existing register in-place if doing so would change the size of the underlying register allocation size, as given by REGMODE_NATURAL_SIZE. Without this, many tests fail in adjust_reg_mode after SVE is added. One example is gcc.c-torture/compile/20090401-1.c. 2017-10-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (can_change_dest_mode): Reject changes in REGMODE_NATURAL_SIZE. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r253717 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0e29ae8a95d..3b897e2dde7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-10-13 Richard Sandiford + Alan Hayward + David Sherwood + + * combine.c (can_change_dest_mode): Reject changes in + REGMODE_NATURAL_SIZE. + 2017-10-13 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/combine.c b/gcc/combine.c index aa246e67bab..3b96d86bdb3 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -2475,6 +2475,12 @@ can_change_dest_mode (rtx x, int added_sets, machine_mode mode) if (!REG_P (x)) return false; + /* Don't change between modes with different underlying register sizes, + since this could lead to invalid subregs. */ + if (REGMODE_NATURAL_SIZE (mode) + != REGMODE_NATURAL_SIZE (GET_MODE (x))) + return false; + regno = REGNO (x); /* Allow hard registers if the new mode is legal, and occupies no more registers than the old mode. */