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 optimization/6842


Hi!

The following testcase ICEs, because gen_lowpart_for_combine is called with
(V8QImode, (const_double:VOIDmode ...)), cannot be simplified and creating
(subreg:V8QImode (const_double:VOIDmode ...) 0) is not valid subreg.
But combine_simplify_rtx in this case shouldn't ICE, but simply not optimize
(like the simplify_subreg below this call would do if combine decided not
to optimize using gen_lowpart_for_combine). As gen_lowpart_for_combine can
optimize some VOIDmode operands, I'm calling gen_lowpart_common to see if it
would succeed or not.
Ok to commit if testing succeeds?

2002-05-31  Jakub Jelinek  <jakub@redhat.com>

	PR optimization/6842
	* combine.c (combine_simplify_rtx) [SUBREG]: Don't ICE if VOIDmode
	operand subreg cannot be simplified.

	* gcc.dg/20020531-1.c: New test.

--- gcc/testsuite/gcc.dg/20020531-1.c.jj	Fri May 31 17:15:15 2002
+++ gcc/testsuite/gcc.dg/20020531-1.c	Fri May 31 17:13:50 2002
@@ -0,0 +1,21 @@
+/* PR optimization/6842
+   This testcase caused ICE when trying to optimize V8QI subreg of VOIDmode
+   CONST_DOUBLE.  */
+/* { dg-do compile { target i?86-*-* } } */
+/* { dg-options "-O2 -mmmx" } */
+
+typedef int __v8qi __attribute__ ((__mode__ (__V8QI__)));
+extern void abort (void);
+extern void exit (int);
+
+void foo (void)
+{
+  unsigned long long a = 0x0102030405060708LL;
+  unsigned long long b = 0x1020304050607080LL;
+  unsigned long long c;
+
+  c = (unsigned long long) __builtin_ia32_paddusb ((__v8qi) a, (__v8qi) b);
+  __builtin_ia32_emms ();
+  if (c != 0x1122334455667788)
+    abort ();
+}
--- gcc/combine.c.jj	Thu May 23 10:22:59 2002
+++ gcc/combine.c	Fri May 31 17:05:09 2002
@@ -3863,7 +3863,12 @@ combine_simplify_rtx (x, op0_mode, last,
 
       /* simplify_subreg can't use gen_lowpart_for_combine.  */
       if (CONSTANT_P (SUBREG_REG (x))
-	  && subreg_lowpart_offset (mode, op0_mode) == SUBREG_BYTE (x))
+	  && subreg_lowpart_offset (mode, op0_mode) == SUBREG_BYTE (x)
+	     /* Don't call gen_lowpart_for_combine if the inner mode
+		is VOIDmode and we cannot simplify it, as SUBREG without
+		inner mode is invalid.  */
+	  && (GET_MODE (SUBREG_REG (x)) != VOIDmode
+	      || gen_lowpart_common (mode, SUBREG_REG (x))))
 	return gen_lowpart_for_combine (mode, SUBREG_REG (x));
 
       if (GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_CC)

	Jakub


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