From a9b76c8962410173ba0351b5b05b5f1f91742fc6 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 1 Nov 2017 08:54:22 +0000 Subject: [PATCH] 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-11-01 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: r254291 --- gcc/ChangeLog | 7 +++++++ gcc/combine.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c653194a4c..1886218f7b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-11-01 Richard Sandiford + Alan Hayward + David Sherwood + + * combine.c (can_change_dest_mode): Reject changes in + REGMODE_NATURAL_SIZE. + 2017-10-31 Sandra Loosemore * configure.ac (--enable-libssp): New. diff --git a/gcc/combine.c b/gcc/combine.c index 93adfc11be7..4afae213a3f 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -2478,6 +2478,12 @@ can_change_dest_mode (rtx x, int added_sets, machine_mode mode) != REGMODE_NATURAL_SIZE (GET_MODE (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. */ -- 2.30.2