This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cprop_reg problem on sparc


From: Eric Botcazou <ebotcazou@adacore.com>
Date: Thu, 27 Oct 2011 23:55:00 +0200

>> I quickly tried the patch below, but this does not prevent the
>> transformation.
> 
> The quoted code is in copyprop_hardreg_forward_1.

Indeed :-)

This patch below works for the specific test case, and I'll post to
gcc-patches and commit it after regstrapping.

Thanks Eric!

--------------------
Fix illegal register substitutions on big-endian during cprop_reg.

	* regcprop.c (copyprop_hardreg_forward_1): Reject the
	transformation when we narrow the mode on big endian.
---
 gcc/ChangeLog  |    5 +++++
 gcc/regcprop.c |    8 ++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 403fb60..54e059e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2011-10-27  David S. Miller  <davem@davemloft.net>
+
+	* regcprop.c (copyprop_hardreg_forward_1): Reject the
+	transformation when we narrow the mode on big endian.
+
 2011-10-27  Jakub Jelinek  <jakub@redhat.com>
 
 	* config/i386/sse.md (avx_cvtpd2dq256_2, avx_cvttpd2dq256_2,
diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index ad92a64..b0f0343 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -824,6 +824,14 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd)
 	      if (hard_regno_nregs[regno][mode]
 		  > hard_regno_nregs[regno][vd->e[regno].mode])
 		goto no_move_special_case;
+
+	      /* And likewise, if we are narrowing on big endian the transformation
+		 is also invalid.  */
+	      if (hard_regno_nregs[regno][mode]
+		  < hard_regno_nregs[regno][vd->e[regno].mode]
+		  && (GET_MODE_SIZE (vd->e[regno].mode) > UNITS_PER_WORD
+		      ? WORDS_BIG_ENDIAN : BYTES_BIG_ENDIAN))
+		goto no_move_special_case;
 	    }
 
 	  /* If the destination is also a register, try to find a source
-- 
1.7.6.401.g6a319


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]