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] PR c/8439


This is a high-priority PR, regression both on the mainline and the branch. 
The compiler ICEs in instantiate_virtual_regs_1 on the following insn:

(insn 9 6 10 (parallel[ 
            (set (mem/f:SI (reg/f:SI 53 virtual-incoming-args) [0 p+0 S4 A32])
                (plus:SI (mem/f:SI (reg/f:SI 53 virtual-incoming-args) [0 p+0 
S4 A32])
                    (const_int 0 [0x0])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (nil))

because the recognizer again chokes on the (plus (mem) (const_int 0)) pattern.

The proposed fix is to teach expand_increment not to emit insn when the 
increment is null. Bootstrapped/regtested (c,c++,objc,f77 mainline) on 
i586-redhat-linux-gnu.


2002-11-04  Eric Botcazou  <ebotcazou@libertysurf.fr>

	PR c/8439
	* expr.c (expand_increment): Don't emit insn if the
	increment is null.

-- 
Eric Botcazou
--- gcc/expr.c.orig	Sun Nov  3 23:25:36 2002
+++ gcc/expr.c	Sun Nov  3 23:26:41 2002
@@ -9388,6 +9388,9 @@
 
   temp = get_last_insn ();
   op0 = expand_expr (incremented, NULL_RTX, VOIDmode, 0);
+  op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
+  if (op1 == const0_rtx)
+    return op0;  
 
   /* If OP0 is a SUBREG made for a promoted variable, we cannot increment
      in place but instead must do sign- or zero-extension during assignment,
@@ -9418,7 +9421,6 @@
 
   op0_is_copy = ((GET_CODE (op0) == SUBREG || GET_CODE (op0) == REG)
 		 && temp != get_last_insn ());
-  op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0);
 
   /* Decide whether incrementing or decrementing.  */
   if (TREE_CODE (exp) == POSTDECREMENT_EXPR
/* PR c/8439 */
/* Verify that GCC properly handles null increments. */

struct empty {
};

void foo(struct empty *p)
{
   p++;
}

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