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]

Re: alpha bootstrap fix


> Thu May 17 23:19:46 CEST 2001  Jan Hubicka  <jh@suse.cz>
> 
>         * combine.c (combine_simplify_rtx): Use swap_commutative_operands_p.
>         (gen_binary): Likewise.
>         * optabs.c (emit_cmp_and_jump_insns, emit_conditional_move): Likewise.
>         * simplify-rtx.c (simplify_gen_binary,
>         simplify_gen_relational): Likewise.
> 
> The change to emit_cmp_and_jump_insns, at minimum, is incorrect.
> This is used e.g. by compare_from_rtx from emit_store_flag to 
> generate setcc instructions.  We have no way of mentioning this
> change of comparison code to upper layers, resulting in bad code.
Hi,
I've just regtested and bootstrapped the attached patch.  It converts more
places to use swap_commutative_operands_p and should solve the problem
mentioned in same way as it has been solved previously - by keeping the
conditions in the sync with the other places.

Can you please try if this patch works for Alpha (I am in the middle of mips
bootstrap) in case you consider it as better then the original fix?
I believe it is :)

Honza

Mon May 21 12:58:03 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* combine.c (gen_binary): Use swap_commutative_operands_p
	(simplify_comparison): Likewise.
	* expmed.c (emit_store_flag): Likewise.
	* expr.c (compare_from_rtx): Likewise.
	(do_compare_rtx_and_jump): Likewise.
	* optabs.c (emit_cmp_and_jump_insn): Revert last patch; note
	that condition must be kept in the sync with other places.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.202
diff -c -3 -p -r1.202 combine.c
*** combine.c	2001/05/18 21:04:56	1.202
--- combine.c	2001/05/21 09:52:51
*************** gen_binary (code, mode, op0, op1)
*** 9784,9791 ****
    rtx tem;
  
    if (GET_RTX_CLASS (code) == 'c'
!       && (GET_CODE (op0) == CONST_INT
! 	  || (CONSTANT_P (op0) && GET_CODE (op1) != CONST_INT)))
      tem = op0, op0 = op1, op1 = tem;
  
    if (GET_RTX_CLASS (code) == '<')
--- 9784,9790 ----
    rtx tem;
  
    if (GET_RTX_CLASS (code) == 'c'
!       && swap_commutative_operands_p (op0, op1))
      tem = op0, op0 = op1, op1 = tem;
  
    if (GET_RTX_CLASS (code) == '<')
*************** simplify_comparison (code, pop0, pop1)
*** 9990,9996 ****
    /* If the first operand is a constant, swap the operands and adjust the
       comparison code appropriately, but don't do this if the second operand
       is already a constant integer.  */
!   if (CONSTANT_P (op0) && GET_CODE (op1) != CONST_INT)
      {
        tem = op0, op0 = op1, op1 = tem;
        code = swap_condition (code);
--- 9989,9995 ----
    /* If the first operand is a constant, swap the operands and adjust the
       comparison code appropriately, but don't do this if the second operand
       is already a constant integer.  */
!   if (swap_commutative_operands_p (op0, op1))
      {
        tem = op0, op0 = op1, op1 = tem;
        code = swap_condition (code);
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expmed.c,v
retrieving revision 1.79
diff -c -3 -p -r1.79 expmed.c
*** expmed.c	2001/04/12 03:41:36	1.79
--- expmed.c	2001/05/21 09:52:53
*************** emit_store_flag (target, code, op0, op1,
*** 4226,4233 ****
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
!       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
      {
        tem = op0;
        op0 = op1;
--- 4226,4232 ----
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if (swap_commutative_operands (op0, op1))
      {
        tem = op0;
        op0 = op1;
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.318
diff -c -3 -p -r1.318 expr.c
*** expr.c	2001/05/20 21:36:35	1.318
--- expr.c	2001/05/21 09:52:56
*************** compare_from_rtx (op0, op1, code, unsign
*** 10107,10114 ****
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
!       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
      {
        tem = op0;
        op0 = op1;
--- 10107,10113 ----
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if (swap_commutative_operands_p (op0, op1))
      {
        tem = op0;
        op0 = op1;
*************** do_compare_rtx_and_jump (op0, op1, code,
*** 10190,10197 ****
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
!       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
      {
        tem = op0;
        op0 = op1;
--- 10189,10195 ----
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if (swap_commutative_operands_p (op0, op1))
      {
        tem = op0;
        op0 = op1;
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/optabs.c,v
retrieving revision 1.98
diff -c -3 -p -r1.98 optabs.c
*** optabs.c	2001/05/21 01:33:53	1.98
--- optabs.c	2001/05/21 09:52:58
*************** emit_cmp_and_jump_insns (x, y, compariso
*** 3292,3304 ****
  
    /* We may not swap in the general case, since this is called from 
       compare_from_rtx, and we have no way of reporting the changed
!      comparison code.  */
!   if (comparison == swap_condition (comparison)
!       && swap_commutative_operands_p (x, y))
      {
        /* Swap operands and condition to ensure canonical RTL.  */
        op0 = y;
        op1 = x;
      }
    else
      {
--- 3292,3307 ----
  
    /* We may not swap in the general case, since this is called from 
       compare_from_rtx, and we have no way of reporting the changed
!      comparison code.
!  
!      This condition must be kept in the sync with compare_from_rtx
!      and emit_store_flag fucntions.  */
!   if (swap_commutative_operands_p (x, y))
      {
        /* Swap operands and condition to ensure canonical RTL.  */
        op0 = y;
        op1 = x;
+       comparison = swap_condition (comparison);
      }
    else
      {
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.53
diff -c -3 -p -r1.53 simplify-rtx.c
*** simplify-rtx.c	2001/05/17 21:21:21	1.53
--- simplify-rtx.c	2001/05/21 09:52:59
*************** simplify_relational_operation (code, mod
*** 1817,1824 ****
      return 0;
  
    /* Make sure the constant is second.  */
!   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
!       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
      {
        tem = op0, op0 = op1, op1 = tem;
        code = swap_condition (code);
--- 1817,1823 ----
      return 0;
  
    /* Make sure the constant is second.  */
!   if (swap_commutative_operands_p (op0, op1))
      {
        tem = op0, op0 = op1, op1 = tem;
        code = swap_condition (code);


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