From: Segher Boessenkool Date: Wed, 23 Nov 2016 23:30:38 +0000 (+0100) Subject: combine: Query can_change_dest_mode before changing dest mode X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=469585df2d22f325c50e1614d397a0a38b29df6f;p=gcc.git combine: Query can_change_dest_mode before changing dest mode As reported in https://gcc.gnu.org/ml/gcc-patches/2016-11/msg02388.html . Changing the mode of a hard register can lead to problems, or at least it can make worse code if the result will need reloads. * combine.c (change_zero_ext): Only change the mode of a hard register destination if can_change_dest_mode holds for that. From-SVN: r242812 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 46b023e6400..1cd24041b5b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-11-23 Segher Boessenkool + + * combine.c (change_zero_ext): Only change the mode of a hard register + destination if can_change_dest_mode holds for that. + 2016-11-23 Jeff Law * varasm.c (assemble_name): Increase buffer size for name. diff --git a/gcc/combine.c b/gcc/combine.c index ae25ef35ed9..ce6cfde534d 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11230,7 +11230,8 @@ change_zero_ext (rtx pat) else if (GET_CODE (x) == ZERO_EXTEND && SCALAR_INT_MODE_P (mode) && REG_P (XEXP (x, 0)) - && HARD_REGISTER_P (XEXP (x, 0))) + && HARD_REGISTER_P (XEXP (x, 0)) + && can_change_dest_mode (XEXP (x, 0), 0, mode)) { size = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))); x = gen_rtx_REG (mode, REGNO (XEXP (x, 0)));