This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] combine: Query can_change_dest_mode before changing dest mode
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: avr at gjlay dot de, Segher Boessenkool <segher at kernel dot crashing dot org>
- Date: Wed, 23 Nov 2016 23:27:30 +0000
- Subject: [PATCH] combine: Query can_change_dest_mode before changing dest mode
- Authentication-results: sourceware.org; auth=none
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.
Tested on avr-elf on the test in that email, and bootstrapped and
regression checked on powerpc64-linux {-m32,-m64}. Committing to trunk.
Segher
2016-11-23 Segher Boessenkool <segher@kernel.crashing.org>
* combine.c (change_zero_ext): Only change the mode of a hard register
destination if can_change_dest_mode holds for that.
---
gcc/combine.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/combine.c b/gcc/combine.c
index eef917a..c8a71eb 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -11287,7 +11287,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)));
--
1.9.3