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]

Re: PATCH: optimization/5844: Bad code generated for -O2 -mcpu=i586


On Wed, Mar 06, 2002 at 01:45:07PM -0800, Richard Henderson wrote:
> The mem in insn 83 is shared with the mem in insn 85.  This
> is the bug.

Fixed thus.


r~


	* genemit.c (gen_exp): New argument used.  Invoke copy_rtx
	if used indicates we've already emitted one copy of an operand.
	(gen_insn, gen_expand, output_add_clobbers): Supply a null used.
	(gen_split): Supply a non-null used.

Index: genemit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genemit.c,v
retrieving revision 1.71
diff -c -p -d -r1.71 genemit.c
*** genemit.c	2001/12/09 16:31:46	1.71
--- genemit.c	2002/03/06 22:09:03
*************** struct clobber_ent
*** 58,64 ****
  static void max_operand_1		PARAMS ((rtx));
  static int max_operand_vec		PARAMS ((rtx, int));
  static void print_code			PARAMS ((RTX_CODE));
! static void gen_exp			PARAMS ((rtx, enum rtx_code));
  static void gen_insn			PARAMS ((rtx));
  static void gen_expand			PARAMS ((rtx));
  static void gen_split			PARAMS ((rtx));
--- 58,64 ----
  static void max_operand_1		PARAMS ((rtx));
  static int max_operand_vec		PARAMS ((rtx, int));
  static void print_code			PARAMS ((RTX_CODE));
! static void gen_exp			PARAMS ((rtx, enum rtx_code, char *));
  static void gen_insn			PARAMS ((rtx));
  static void gen_expand			PARAMS ((rtx));
  static void gen_split			PARAMS ((rtx));
*************** gen_rtx_scratch (x, subroutine_type)
*** 155,163 ****
     substituting any operand references appearing within.  */
  
  static void
! gen_exp (x, subroutine_type)
       rtx x;
       enum rtx_code subroutine_type;
  {
    RTX_CODE code;
    int i;
--- 155,164 ----
     substituting any operand references appearing within.  */
  
  static void
! gen_exp (x, subroutine_type, used)
       rtx x;
       enum rtx_code subroutine_type;
+      char *used;
  {
    RTX_CODE code;
    int i;
*************** gen_exp (x, subroutine_type)
*** 176,181 ****
--- 177,191 ----
      {
      case MATCH_OPERAND:
      case MATCH_DUP:
+       if (used)
+ 	{
+ 	  if (used[XINT (x, 0)])
+ 	    {
+ 	      printf ("copy_rtx (operand%d)", XINT (x, 0));
+ 	      return;
+ 	    }
+ 	  used[XINT (x, 0)] = 1;
+ 	}
        printf ("operand%d", XINT (x, 0));
        return;
  
*************** gen_exp (x, subroutine_type)
*** 188,194 ****
        for (i = 0; i < XVECLEN (x, 1); i++)
  	{
  	  printf (",\n\t\t");
! 	  gen_exp (XVECEXP (x, 1, i), subroutine_type);
  	}
        printf (")");
        return;
--- 198,204 ----
        for (i = 0; i < XVECLEN (x, 1); i++)
  	{
  	  printf (",\n\t\t");
! 	  gen_exp (XVECEXP (x, 1, i), subroutine_type, used);
  	}
        printf (")");
        return;
*************** gen_exp (x, subroutine_type)
*** 199,205 ****
        for (i = 0; i < XVECLEN (x, 2); i++)
  	{
  	  printf (",\n\t\t");
! 	  gen_exp (XVECEXP (x, 2, i), subroutine_type);
  	}
        printf (")");
        return;
--- 209,215 ----
        for (i = 0; i < XVECLEN (x, 2); i++)
  	{
  	  printf (",\n\t\t");
! 	  gen_exp (XVECEXP (x, 2, i), subroutine_type, used);
  	}
        printf (")");
        return;
*************** gen_exp (x, subroutine_type)
*** 262,268 ****
  	break;
        printf (",\n\t");
        if (fmt[i] == 'e' || fmt[i] == 'u')
! 	gen_exp (XEXP (x, i), subroutine_type);
        else if (fmt[i] == 'i')
  	printf ("%u", XINT (x, i));
        else if (fmt[i] == 's')
--- 272,278 ----
  	break;
        printf (",\n\t");
        if (fmt[i] == 'e' || fmt[i] == 'u')
! 	gen_exp (XEXP (x, i), subroutine_type, used);
        else if (fmt[i] == 'i')
  	printf ("%u", XINT (x, i));
        else if (fmt[i] == 's')
*************** gen_exp (x, subroutine_type)
*** 274,280 ****
  	  for (j = 0; j < XVECLEN (x, i); j++)
  	    {
  	      printf (",\n\t\t");
! 	      gen_exp (XVECEXP (x, i, j), subroutine_type);
  	    }
  	  printf (")");
  	}
--- 284,290 ----
  	  for (j = 0; j < XVECLEN (x, i); j++)
  	    {
  	      printf (",\n\t\t");
! 	      gen_exp (XVECEXP (x, i, j), subroutine_type, used);
  	    }
  	  printf (")");
  	}
*************** gen_insn (insn)
*** 397,403 ****
    if (XVECLEN (insn, 1) == 1)
      {
        printf ("  return ");
!       gen_exp (XVECEXP (insn, 1, 0), DEFINE_INSN);
        printf (";\n}\n\n");
      }
    else
--- 407,413 ----
    if (XVECLEN (insn, 1) == 1)
      {
        printf ("  return ");
!       gen_exp (XVECEXP (insn, 1, 0), DEFINE_INSN, NULL);
        printf (";\n}\n\n");
      }
    else
*************** gen_insn (insn)
*** 408,414 ****
        for (i = 0; i < XVECLEN (insn, 1); i++)
  	{
  	  printf (",\n\t\t");
! 	  gen_exp (XVECEXP (insn, 1, i), DEFINE_INSN);
  	}
        printf ("));\n}\n\n");
      }
--- 418,424 ----
        for (i = 0; i < XVECLEN (insn, 1); i++)
  	{
  	  printf (",\n\t\t");
! 	  gen_exp (XVECEXP (insn, 1, i), DEFINE_INSN, NULL);
  	}
        printf ("));\n}\n\n");
      }
*************** gen_expand (expand)
*** 454,460 ****
        && XVECLEN (expand, 1) == 1)
      {
        printf ("  return ");
!       gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND);
        printf (";\n}\n\n");
        return;
      }
--- 464,470 ----
        && XVECLEN (expand, 1) == 1)
      {
        printf ("  return ");
!       gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND, NULL);
        printf (";\n}\n\n");
        return;
      }
*************** gen_expand (expand)
*** 535,541 ****
  	printf ("  emit (");
        else
  	printf ("  emit_insn (");
!       gen_exp (next, DEFINE_EXPAND);
        printf (");\n");
        if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
  	  && GET_CODE (SET_SRC (next)) == LABEL_REF)
--- 545,551 ----
  	printf ("  emit (");
        else
  	printf ("  emit_insn (");
!       gen_exp (next, DEFINE_EXPAND, NULL);
        printf (");\n");
        if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
  	  && GET_CODE (SET_SRC (next)) == LABEL_REF)
*************** gen_split (split)
*** 561,566 ****
--- 571,577 ----
    const char *const name =
      ((GET_CODE (split) == DEFINE_PEEPHOLE2) ? "peephole2" : "split");
    const char *unused;
+   char *used;
  
    if (XVEC (split, 0) == 0)
      fatal ("define_%s (definition %d) lacks a pattern", name,
*************** gen_split (split)
*** 574,579 ****
--- 585,591 ----
    max_operand_vec (split, 2);
    operands = MAX (max_opno, MAX (max_dup_opno, max_scratch_opno)) + 1;
    unused = (operands == 0 ? " ATTRIBUTE_UNUSED" : "");
+   used = xcalloc (1, operands);
  
    /* Output the prototype, function name and argument declarations.  */
    if (GET_CODE (split) == DEFINE_PEEPHOLE2)
*************** gen_split (split)
*** 645,651 ****
  	printf ("  emit (");
        else
  	printf ("  emit_insn (");
!       gen_exp (next, GET_CODE (split));
        printf (");\n");
        if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
  	  && GET_CODE (SET_SRC (next)) == LABEL_REF)
--- 657,663 ----
  	printf ("  emit (");
        else
  	printf ("  emit_insn (");
!       gen_exp (next, GET_CODE (split), used);
        printf (");\n");
        if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
  	  && GET_CODE (SET_SRC (next)) == LABEL_REF)
*************** gen_split (split)
*** 658,663 ****
--- 670,677 ----
    printf ("  _val = gen_sequence ();\n");
    printf ("  end_sequence ();\n");
    printf ("  return _val;\n}\n\n");
+ 
+   free (used);
  }
  
  /* Write a function, `add_clobbers', that is given a PARALLEL of sufficient
*************** output_add_clobbers ()
*** 686,692 ****
  	{
  	  printf ("      XVECEXP (pattern, 0, %d) = ", i);
  	  gen_exp (XVECEXP (clobber->pattern, 1, i),
! 		   GET_CODE (clobber->pattern));
  	  printf (";\n");
  	}
  
--- 700,706 ----
  	{
  	  printf ("      XVECEXP (pattern, 0, %d) = ", i);
  	  gen_exp (XVECEXP (clobber->pattern, 1, i),
! 		   GET_CODE (clobber->pattern), NULL);
  	  printf (";\n");
  	}
  


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