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 ICE on small loop


Hi,

A little gem from ACTE: the following seemingly innocuous loop

void foo(void)
{
  char c;

  for (c = -75; c <= 75; c++)
    ;
}

crashes every compiler since GCC 3.1 at -O2 with

20040214-1.c:7: error: unrecognizable insn:
(insn:HI 58 32 10 0 (nil) (set (reg/v:QI 58)
        (const_int 151 [0x97])) -1 (nil)
    (expr_list:REG_EQUAL (const_int 151 [0x97])
        (nil)))

but not GCC 3.0.x, so we have a regression.


Bootstrapped/regtested on i586-redhat-linux-gnu (3.4 branch).  OK for 
mainline and 3.4 branch?


2004-02-14  Olivier Hainque  <hainque@act-europe.fr>

	* loop.c (check_dbra_loop): Use gen_int_mode instead of GEN_INT
	for start_value when it is directly moved into reg, and factorize
	the retrieval of GET_MODE (reg). 


2004-02-14  Eric Botcazou  <ebotcazou@act-europe.fr>

	* gcc.c-torture/compile/20040214-1.c: New test.


-- 
Eric Botcazou
Wed Dec 17 10:44:18 2003  Olivier Hainque  <hainque@act-europe.fr>

	* loop.c (check_dbra_loop): Use gen_int_mode instead of GEN_INT
	for start_value when it is directly moved into reg, and factorize
	the retrieval of GET_MODE (reg). 


Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.491
diff -u -p -r1.491 loop.c
--- loop.c	6 Feb 2004 20:10:35 -0000	1.491
+++ loop.c	12 Feb 2004 12:52:58 -0000
@@ -8015,6 +8015,7 @@ check_dbra_loop (struct loop *loop, int 
   struct loop_ivs *ivs = LOOP_IVS (loop);
   struct iv_class *bl;
   rtx reg;
+  enum machine_mode mode;
   rtx jump_label;
   rtx final_value;
   rtx start_value;
@@ -8435,6 +8436,7 @@ check_dbra_loop (struct loop *loop, int 
 
 	      /* Save some info needed to produce the new insns.  */
 	      reg = bl->biv->dest_reg;
+	      mode = GET_MODE (reg);
 	      jump_label = condjump_label (PREV_INSN (loop_end));
 	      new_add_val = GEN_INT (-INTVAL (bl->biv->add_val));
 
@@ -8446,12 +8448,12 @@ check_dbra_loop (struct loop *loop, int 
 	      if (initial_value == const0_rtx
 		  && GET_CODE (comparison_value) == CONST_INT)
 		{
-		  start_value = GEN_INT (comparison_val - add_adjust);
+		  start_value
+		    = gen_int_mode (comparison_val - add_adjust, mode);
 		  loop_insn_hoist (loop, gen_move_insn (reg, start_value));
 		}
 	      else if (GET_CODE (initial_value) == CONST_INT)
 		{
-		  enum machine_mode mode = GET_MODE (reg);
 		  rtx offset = GEN_INT (-INTVAL (initial_value) - add_adjust);
 		  rtx add_insn = gen_add3_insn (reg, comparison_value, offset);
 
@@ -8467,7 +8469,6 @@ check_dbra_loop (struct loop *loop, int 
 		}
 	      else if (! add_adjust)
 		{
-		  enum machine_mode mode = GET_MODE (reg);
 		  rtx sub_insn = gen_sub3_insn (reg, comparison_value,
 						initial_value);
 
@@ -8525,7 +8526,7 @@ check_dbra_loop (struct loop *loop, int 
 	      /* Add new compare/branch insn at end of loop.  */
 	      start_sequence ();
 	      emit_cmp_and_jump_insns (reg, const0_rtx, cmp_code, NULL_RTX,
-				       GET_MODE (reg), 0,
+				       mode, 0,
 				       XEXP (jump_label, 0));
 	      tem = get_insns ();
 	      end_sequence ();
void foo(void)
{
  char c;

  for (c = -75; c <= 75; c++)
    ;
}

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