public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use double_ints in get_inner_reference
@ 2010-06-17 12:27 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2010-06-17 12:27 UTC (permalink / raw)
  To: gcc-patches


for bit_offset, to avoid generating trees all the time.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2010-06-17  Richard Guenther  <rguenther@suse.de>

	* expr.c (get_inner_reference): Use double_int for bit_offset
	calculation.

Index: gcc/expr.c
===================================================================
*** gcc/expr.c	(revision 160889)
--- gcc/expr.c	(working copy)
*************** get_inner_reference (tree exp, HOST_WIDE
*** 5984,5990 ****
    enum machine_mode mode = VOIDmode;
    bool blkmode_bitfield = false;
    tree offset = size_zero_node;
!   tree bit_offset = bitsize_zero_node;
  
    /* First get the mode, signedness, and size.  We do this from just the
       outermost expression.  */
--- 5984,5990 ----
    enum machine_mode mode = VOIDmode;
    bool blkmode_bitfield = false;
    tree offset = size_zero_node;
!   double_int bit_offset = double_int_zero;
  
    /* First get the mode, signedness, and size.  We do this from just the
       outermost expression.  */
*************** get_inner_reference (tree exp, HOST_WIDE
*** 6045,6052 ****
        switch (TREE_CODE (exp))
  	{
  	case BIT_FIELD_REF:
! 	  bit_offset = size_binop (PLUS_EXPR, bit_offset,
! 				   TREE_OPERAND (exp, 2));
  	  break;
  
  	case COMPONENT_REF:
--- 6045,6053 ----
        switch (TREE_CODE (exp))
  	{
  	case BIT_FIELD_REF:
! 	  bit_offset
! 	    = double_int_add (bit_offset,
! 			      tree_to_double_int (TREE_OPERAND (exp, 2)));
  	  break;
  
  	case COMPONENT_REF:
*************** get_inner_reference (tree exp, HOST_WIDE
*** 6061,6068 ****
  	      break;
  
  	    offset = size_binop (PLUS_EXPR, offset, this_offset);
! 	    bit_offset = size_binop (PLUS_EXPR, bit_offset,
! 				     DECL_FIELD_BIT_OFFSET (field));
  
  	    /* ??? Right now we don't do anything with DECL_OFFSET_ALIGN.  */
  	  }
--- 6062,6070 ----
  	      break;
  
  	    offset = size_binop (PLUS_EXPR, offset, this_offset);
! 	    bit_offset = double_int_add (bit_offset,
! 					 tree_to_double_int
! 					   (DECL_FIELD_BIT_OFFSET (field)));
  
  	    /* ??? Right now we don't do anything with DECL_OFFSET_ALIGN.  */
  	  }
*************** get_inner_reference (tree exp, HOST_WIDE
*** 6094,6101 ****
  	  break;
  
  	case IMAGPART_EXPR:
! 	  bit_offset = size_binop (PLUS_EXPR, bit_offset,
! 				   bitsize_int (*pbitsize));
  	  break;
  
  	case VIEW_CONVERT_EXPR:
--- 6096,6103 ----
  	  break;
  
  	case IMAGPART_EXPR:
! 	  bit_offset = double_int_add (bit_offset,
! 				       uhwi_to_double_int (*pbitsize));
  	  break;
  
  	case VIEW_CONVERT_EXPR:
*************** get_inner_reference (tree exp, HOST_WIDE
*** 6126,6134 ****
       this conversion.  */
    if (host_integerp (offset, 0))
      {
!       double_int tem = double_int_mul (tree_to_double_int (offset),
! 				       uhwi_to_double_int (BITS_PER_UNIT));
!       tem = double_int_add (tem, tree_to_double_int (bit_offset));
        if (double_int_fits_in_shwi_p (tem))
  	{
  	  *pbitpos = double_int_to_shwi (tem);
--- 6128,6138 ----
       this conversion.  */
    if (host_integerp (offset, 0))
      {
!       double_int tem = double_int_lshift (tree_to_double_int (offset),
! 					  BITS_PER_UNIT == 8
! 					  ? 3 : exact_log2 (BITS_PER_UNIT),
! 					  HOST_BITS_PER_DOUBLE_INT, true);
!       tem = double_int_add (tem, bit_offset);
        if (double_int_fits_in_shwi_p (tem))
  	{
  	  *pbitpos = double_int_to_shwi (tem);
*************** get_inner_reference (tree exp, HOST_WIDE
*** 6139,6145 ****
    /* Otherwise, split it up.  */
    if (offset)
      {
!       *pbitpos = tree_low_cst (bit_offset, 0);
        *poffset = offset;
      }
  
--- 6143,6149 ----
    /* Otherwise, split it up.  */
    if (offset)
      {
!       *pbitpos = double_int_to_shwi (bit_offset);
        *poffset = offset;
      }
  

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-17 12:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-17 12:27 [PATCH] Use double_ints in get_inner_reference Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).