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] for PR 28887


Hello,

prefetching will try generating builtin_prefetch (&ref) even for
references that are not addressable (bitfields, etc.).  This patch
makes it strip the non-addressable components first.

Bootstrapped & regtested on x86_64.

Zdenek

	PR tree-optimization/28887
	* tree-ssa-loop-prefetch.c (analyze_ref): Strip nonaddressable
	component parts from the reference.
	(gather_memory_references_ref): Record the reference without the
	nonaddressable component parts.

Index: tree-ssa-loop-prefetch.c
===================================================================
*** tree-ssa-loop-prefetch.c	(revision 116186)
--- tree-ssa-loop-prefetch.c	(working copy)
*************** idx_analyze_ref (tree base, tree *index,
*** 387,404 ****
    return true;
  }
  
! /* Tries to express REF in shape &BASE + STEP * iter + DELTA, where DELTA and
     STEP are integer constants and iter is number of iterations of LOOP.  The
!    reference occurs in statement STMT.  */
  
  static bool
! analyze_ref (struct loop *loop, tree ref, tree *base,
  	     HOST_WIDE_INT *step, HOST_WIDE_INT *delta,
  	     tree stmt)
  {
    struct ar_data ar_data;
    tree off;
    HOST_WIDE_INT bit_offset;
  
    *step = 0;
    *delta = 0;
--- 387,406 ----
    return true;
  }
  
! /* Tries to express REF_P in shape &BASE + STEP * iter + DELTA, where DELTA and
     STEP are integer constants and iter is number of iterations of LOOP.  The
!    reference occurs in statement STMT.  Strips nonaddressable component
!    references from REF_P.  */
  
  static bool
! analyze_ref (struct loop *loop, tree *ref_p, tree *base,
  	     HOST_WIDE_INT *step, HOST_WIDE_INT *delta,
  	     tree stmt)
  {
    struct ar_data ar_data;
    tree off;
    HOST_WIDE_INT bit_offset;
+   tree ref = *ref_p;
  
    *step = 0;
    *delta = 0;
*************** analyze_ref (struct loop *loop, tree ref
*** 408,413 ****
--- 410,417 ----
        && DECL_NONADDRESSABLE_P (TREE_OPERAND (ref, 1)))
      ref = TREE_OPERAND (ref, 0);
  
+   *ref_p = ref;
+ 
    for (; TREE_CODE (ref) == COMPONENT_REF; ref = TREE_OPERAND (ref, 0))
      {
        off = DECL_FIELD_BIT_OFFSET (TREE_OPERAND (ref, 1));
*************** gather_memory_references_ref (struct loo
*** 436,442 ****
    HOST_WIDE_INT step, delta;
    struct mem_ref_group *agrp;
  
!   if (!analyze_ref (loop, ref, &base, &step, &delta, stmt))
      return;
  
    /* Now we know that REF = &BASE + STEP * iter + DELTA, where DELTA and STEP
--- 440,446 ----
    HOST_WIDE_INT step, delta;
    struct mem_ref_group *agrp;
  
!   if (!analyze_ref (loop, &ref, &base, &step, &delta, stmt))
      return;
  
    /* Now we know that REF = &BASE + STEP * iter + DELTA, where DELTA and STEP


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