This is the mail archive of the gcc-patches@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]

[PATCH] Fix PR target/6043


Hi!

The following testcase was ICEing on IA-64 with -O0, because
emit_group_store did not handle storing into CONCAT.
Ok to commit?

2002-03-23  Jakub Jelinek  <jakub@redhat.com>

	PR target/6043
	* expr.c (emit_group_store): Handle storing into CONCAT.

	* g++.dg/opt/conj2.C: New test.

--- gcc/testsuite/g++.dg/opt/conj2.C.jj	Sat Mar 23 22:23:50 2002
+++ gcc/testsuite/g++.dg/opt/conj2.C	Sat Mar 23 22:20:31 2002
@@ -0,0 +1,23 @@
+// PR target/6043
+// This testcase ICEd on IA-64 because emit_group_store
+// did not handle loading CONCAT from register group
+// { dg-do compile }
+
+struct C
+{
+  C (double y, double z) { __real__ x = y; __imag__ x = z; }
+  double r () const { return __real__ x; }
+  double i () const { return __imag__ x; }
+  __complex__ double x;
+};
+
+inline C conj (const C& x)
+{
+  return C (x.r (), - x.i ());
+}
+
+void foo (void)
+{
+  C x (1.0, 1.0);
+  conj (x);
+}
--- gcc/expr.c.jj	Sat Mar 23 12:02:51 2002
+++ gcc/expr.c	Sat Mar 23 22:03:58 2002
@@ -2113,6 +2113,7 @@ emit_group_store (orig_dst, src, ssize)
       HOST_WIDE_INT bytepos = INTVAL (XEXP (XVECEXP (src, 0, i), 1));
       enum machine_mode mode = GET_MODE (tmps[i]);
       unsigned int bytelen = GET_MODE_SIZE (mode);
+      rtx dest = dst;
 
       /* Handle trailing fragments that run over the size of the struct.  */
       if (ssize >= 0 && bytepos + (HOST_WIDE_INT) bytelen > ssize)
@@ -2126,14 +2127,27 @@ emit_group_store (orig_dst, src, ssize)
 	  bytelen = ssize - bytepos;
 	}
 
+      if (GET_CODE (dst) == CONCAT)
+	{
+	  if (bytepos + bytelen <= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0))))
+	    dest = XEXP (dst, 0);
+	  else if (bytepos >= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0))))
+	    {
+	      bytepos -= GET_MODE_SIZE (GET_MODE (XEXP (dst, 0)));
+	      dest = XEXP (dst, 1);
+	    }
+	  else
+	    abort ();
+	}
+
       /* Optimize the access just a bit.  */
-      if (GET_CODE (dst) == MEM
-	  && MEM_ALIGN (dst) >= GET_MODE_ALIGNMENT (mode)
+      if (GET_CODE (dest) == MEM
+	  && MEM_ALIGN (dest) >= GET_MODE_ALIGNMENT (mode)
 	  && bytepos * BITS_PER_UNIT % GET_MODE_ALIGNMENT (mode) == 0
 	  && bytelen == GET_MODE_SIZE (mode))
-	emit_move_insn (adjust_address (dst, mode, bytepos), tmps[i]);
+	emit_move_insn (adjust_address (dest, mode, bytepos), tmps[i]);
       else
-	store_bit_field (dst, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
+	store_bit_field (dest, bytelen * BITS_PER_UNIT, bytepos * BITS_PER_UNIT,
 			 mode, tmps[i], ssize);
     }
 

	Jakub


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