diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0e29ae8a95d3..3b897e2dde74 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 aa246e67babd..3b96d86bdb37 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. */