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: partial def patch


Hi,

On Tue, 12 Jun 2007, Paolo Bonzini wrote:

> Ok, I got round to reviewing this patch.
> 
> > *************** df_read_modify_subreg_p (rtx x)
> > *** 2702,2708 ****
> >       return false;
> >     isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
> >     osize = GET_MODE_SIZE (GET_MODE (x));
> > !   return (isize > osize && isize > UNITS_PER_WORD);
> >   }
> >     --- 2702,2708 ----
> >       return false;
> >     isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
> >     osize = GET_MODE_SIZE (GET_MODE (x));
> > !   return isize > osize;
> >   }
> 
> Leave out this hunk, and put a FIXME saying that it could use
> REGMODE_NATURAL_SIZE instead of UNITS_PER_WORD.  A (subreg:QI (reg:SI A) B)
> clobbers the entire contents of the pseudo A.

Hmm, that was the very first version of the patch, below is my current 
favoured version. You had some concerns about the DF_REF_PARTIAL for the 
subreg, but that's the core part I need to get correct notes in a case 
like this:

(insn 7 28 8 2 ../gcc/gcc/testsuite/gcc.c-torture/execute/20001108-1.c:4 (parallel [
            (set (subreg:SI (reg:DI 30 [ D.1547 ]) 4)
                (mult:SI (reg/v:SI 33 [ x ])
                    (subreg:SI (reg/v:DI 32 [ sum ]) 4)))
            (set (subreg:SI (reg:DI 30 [ D.1547 ]) 0)
                (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (reg/v:SI 33 [ x ]))
                            (sign_extend:DI (subreg:SI (reg/v:DI 32 [ sum ]) 4)))
                        (const_int 32 [0x20]))))
        ]) 182 {*m68k.md:2733} (expr_list:REG_DEAD (reg/v:SI 33 [ x ])
        (expr_list:REG_UNUSED (reg:DI 30 [ D.1547 ])
            (nil))))


BTW tested on i686-linux.

bye, Roman


200x-xx-xx  Roman Zippel <zippel@linux-m68k.org>

	* df-scan.c (df_read_modify_subreg_p): Use REGMODE_NATURAL_SIZE.
	(df_def_record_1): Set (DF_REF_READ_WRITE | DF_REF_PARTIAL) for
	partial register accesses.


---
 gcc/df-scan.c |   31 -----!!!!!!!!!!!!!!!!!!!!!!!!!!
 1 file changed, 5 deletions(-), 26 modifications(!)

Index: gcc/gcc/df-scan.c
===================================================================
*** gcc.orig/gcc/df-scan.c
--- gcc/gcc/df-scan.c
*************** df_read_modify_subreg_p (rtx x)
*** 2701,2707 ****
      return false;
    isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
    osize = GET_MODE_SIZE (GET_MODE (x));
!   return (isize > osize && isize > UNITS_PER_WORD);
  }
  
  
--- 2701,2708 ----
      return false;
    isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
    osize = GET_MODE_SIZE (GET_MODE (x));
!   return isize > osize
! 	 && isize > REGMODE_NATURAL_SIZE (GET_MODE (SUBREG_REG (x)));
  }
  
  
*************** df_def_record_1 (struct df_collection_re
*** 2716,2722 ****
  {
    rtx *loc;
    rtx dst;
-   bool dst_in_strict_lowpart = false;
  
   /* We may recursively call ourselves on EXPR_LIST when dealing with PARALLEL
       construct.  */
--- 2717,2722 ----
*************** df_def_record_1 (struct df_collection_re
*** 2747,2779 ****
    /* Maybe, we should flag the use of STRICT_LOW_PART somehow.  It might
       be handy for the reg allocator.  */
    while (GET_CODE (dst) == STRICT_LOW_PART
! 	 || GET_CODE (dst) == ZERO_EXTRACT
! 	 || df_read_modify_subreg_p (dst))
      {
! #if 0
!       /* Strict low part always contains SUBREG, but we do not want to make
! 	 it appear outside, as whole register is always considered.  */
!       if (GET_CODE (dst) == STRICT_LOW_PART)
! 	{
! 	  loc = &XEXP (dst, 0);
! 	  dst = *loc;
! 	}
! #endif
        loc = &XEXP (dst, 0);
-       if (GET_CODE (dst) == STRICT_LOW_PART)
- 	dst_in_strict_lowpart = true;
        dst = *loc;
-       flags |= DF_REF_READ_WRITE;
- 
      }
  
!   /* Sets to a subreg of a single word register are partial sets if
!      they are wrapped in a strict lowpart, and not partial otherwise.
!   */
!   if (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst))
!       && dst_in_strict_lowpart)
!     flags |= DF_REF_PARTIAL;
!     
    if (REG_P (dst)
        || (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst))))
      df_ref_record (collection_rec, 
--- 2747,2762 ----
    /* Maybe, we should flag the use of STRICT_LOW_PART somehow.  It might
       be handy for the reg allocator.  */
    while (GET_CODE (dst) == STRICT_LOW_PART
! 	 || GET_CODE (dst) == ZERO_EXTRACT)
      {
!       flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL;
        loc = &XEXP (dst, 0);
        dst = *loc;
      }
  
!   if (df_read_modify_subreg_p (dst))
!     flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL;
! 
    if (REG_P (dst)
        || (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst))))
      df_ref_record (collection_rec, 


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