]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/20583 (ICE in output_operand: invalid expression as operand)
authorKazu Hirata <kazu@codesourcery.com>
Mon, 21 Nov 2005 04:41:38 +0000 (04:41 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Mon, 21 Nov 2005 04:41:38 +0000 (04:41 +0000)
gcc/
PR middle-end/20583
* cse.c (cse_insn): Reject invalid forms of CONST earlier.

gcc/testsuite/
PR middle-end/20583
* gcc.c-torture/compile/pr20583.c: New.

From-SVN: r107278

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr20583.c [new file with mode: 0644]

index bc2a54edb17fa6efb19f0b0cd72bf7dfaab44087..5f1e761a4ad079bfdf9ccdcbed08749816c6204b 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-21  Kazu Hirata  <kazu@codesourcery.com>
+
+       PR middle-end/20583
+       * cse.c (cse_insn): Reject invalid forms of CONST earlier.
+
 2005-11-20  Joseph S. Myers  <joseph@codesourcery.com>
 
        * combine.c (try_combine): Do not run subst on i1src and i2src in
index ca9087b0c2f465bcc7a631d4f298a77ab16dfa2d..fdcbe19ba6551a1038df84654be81e7fada4834b 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -5506,6 +5506,22 @@ cse_insn (rtx insn, rtx libcall_insn)
              break;
            }
 
+         /* Reject certain invalid forms of CONST that we create.  */
+         else if (CONSTANT_P (trial)
+                  && GET_CODE (trial) == CONST
+                  /* Reject cases that will cause decode_rtx_const to
+                     die.  On the alpha when simplifying a switch, we
+                     get (const (truncate (minus (label_ref)
+                     (label_ref)))).  */
+                  && (GET_CODE (XEXP (trial, 0)) == TRUNCATE
+                      /* Likewise on IA-64, except without the
+                         truncate.  */
+                      || (GET_CODE (XEXP (trial, 0)) == MINUS
+                          && GET_CODE (XEXP (XEXP (trial, 0), 0)) == LABEL_REF
+                          && GET_CODE (XEXP (XEXP (trial, 0), 1)) == LABEL_REF)))
+           /* Do nothing for this case.  */
+           ;
+
          /* Look for a substitution that makes a valid insn.  */
          else if (validate_change (insn, &SET_SRC (sets[i].rtl), trial, 0))
            {
@@ -5541,17 +5557,6 @@ cse_insn (rtx insn, rtx libcall_insn)
 
          else if (constant_pool_entries_cost
                   && CONSTANT_P (trial)
-                  /* Reject cases that will cause decode_rtx_const to
-                     die.  On the alpha when simplifying a switch, we
-                     get (const (truncate (minus (label_ref)
-                     (label_ref)))).  */
-                  && ! (GET_CODE (trial) == CONST
-                        && GET_CODE (XEXP (trial, 0)) == TRUNCATE)
-                  /* Likewise on IA-64, except without the truncate.  */
-                  && ! (GET_CODE (trial) == CONST
-                        && GET_CODE (XEXP (trial, 0)) == MINUS
-                        && GET_CODE (XEXP (XEXP (trial, 0), 0)) == LABEL_REF
-                        && GET_CODE (XEXP (XEXP (trial, 0), 1)) == LABEL_REF)
                   && (src_folded == 0
                       || (!MEM_P (src_folded)
                           && ! src_folded_force_flag))
index c8414a319e791d8fac6e87c40e073ca108ee0021..48f03546b5f9463321aa3a8ebdd3e9b561e5456a 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-21  Kazu Hirata  <kazu@codesourcery.com>
+
+       PR middle-end/20583
+       * gcc.c-torture/compile/pr20583.c: New.
+
 2005-11-20  Bernd Schmidt  <bernd.schmidt@analog.com>
 
        * gcc.c-torture/execute/usmul.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr20583.c b/gcc/testsuite/gcc.c-torture/compile/pr20583.c
new file mode 100644 (file)
index 0000000..6c5f891
--- /dev/null
@@ -0,0 +1,30 @@
+/* PR target/20583
+   On m68k-none-elf, CSE used to generate
+
+     (set (reg:HI ...)
+          (const:HI (truncate:HI (minus:SI (label_ref ...)
+                                           (label_ref ...)))))
+
+   which output functions do not know how to handle.  Make sure that
+   such a constant will be rejected.  */
+
+void bar (unsigned int);
+
+void
+foo (void)
+{
+  char buf[1] = { 3 };
+  const char *p = buf;
+  const char **q = &p;
+  unsigned int ch;
+  switch (**q)
+    {
+    case 1:  ch = 5; break;
+    case 2:  ch = 4; break;
+    case 3:  ch = 3; break;
+    case 4:  ch = 2; break;
+    case 5:  ch = 1; break;
+    default: ch = 0; break;
+    }
+  bar (ch);
+}