public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove ALIGN_INDIRECT_REF
@ 2010-07-02 12:51 Richard Guenther
  2010-07-05 12:26 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Guenther @ 2010-07-02 12:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: irar


This patch removes ALIGN_INDIRECT_REF from the compiler and instead
represents it as a combination of a BIT_AND_EXPR for pointer re-alignment
and a MEM_REF operation.  This allows all analysis pieces that can
deal with MEM_REF (or formerly INDIRECT_REF) also deal with
ALIGN_INDIRECT_REF.  Especially alias information will be available
on the RTL side.

I am in the process of re-bootstrapping and testing the patch on
powerpc64-linux and plan to commit it on Monday if that worked out.

Thanks,
Richard.

2010-07-02  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-loop-im.c (for_each_index): Do not handle
	ALIGN_INDIRECT_REF.
	(gen_lsm_tmp_name): Likewise.
	* tree-dump.c (dequeue_and_dump): Likewise.
	* tree-pretty-print.c (dump_generic_node): Likewise.
	(op_code_prio): Likewise.
	(op_symbol_code): Likewise.
	* tree.c (staticp): Likewise.
	(build1_stat): Likewise.
	* tree.h (INDIRECT_REF_P): Likewise.
	* fold-const.c (maybe_lvalue_p): Likewise.
	(operand_equal_p): Likewise.
	* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise.
	(ao_ref_init_from_vn_reference): Likewise.
	* tree-ssa-loop-ivopts.c (idx_find_step): Likewise.
	(find_interesting_uses_address): Likewise.
	* dwarf2out.c (loc_list_from_tree): Likewise.
	* gimplify.c (gimplify_expr): Likewise.
	* tree-eh.c (tree_could_trap_p): Likewise.
	* emit-rtl.c (set_mem_attributes_minus_bitpos): Likewise.
	* cfgexpand.c (expand_debug_expr): Likewise.
	* tree-ssa-pre.c (create_component_ref_by_pieces_1): Likewise.
	* tree-ssa-loop-prefetch.c (idx_analyze_ref): Likewise.
	* tree-cfg.c (verify_types_in_gimple_min_lval): Likewise.
	* config/rs6000/rs6000 (rs6000_check_sdmode): Likewise.
	* tree-ssa-operands.c (get_expr_operands): Likewise.
	* expr.c (safe_from_p): Likewise.
	(expand_expr_real_1): Likewise.  TER BIT_AND_EXPRs into MEM_REFs.
	* tree-vect-data-refs.c (vect_setup_realignment): Build
	BIT_AND_EXPR and MEM_REF instead of ALIGN_INDIRECT_REF.
	* tree-vect-stmts.c (vectorizable_load): Likewise.
	* tree.def (ALIGN_INDIRECT_REF): Remove.

Index: gcc/tree-ssa-loop-im.c
===================================================================
*** gcc/tree-ssa-loop-im.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-ssa-loop-im.c	2010-07-02 14:30:00.000000000 +0200
*************** for_each_index (tree *addr_p, bool (*cbc
*** 273,279 ****
  	  return cbck (*addr_p, addr_p, data);
  
  	case MISALIGNED_INDIRECT_REF:
- 	case ALIGN_INDIRECT_REF:
  	case MEM_REF:
  	  nxt = &TREE_OPERAND (*addr_p, 0);
  	  return cbck (*addr_p, nxt, data);
--- 273,278 ----
*************** gen_lsm_tmp_name (tree ref)
*** 1984,1990 ****
    switch (TREE_CODE (ref))
      {
      case MISALIGNED_INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case MEM_REF:
        gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
        lsm_tmp_name_add ("_");
--- 1983,1988 ----
Index: gcc/tree-dump.c
===================================================================
*** gcc/tree-dump.c.orig	2010-06-02 14:20:13.000000000 +0200
--- gcc/tree-dump.c	2010-07-02 14:30:00.000000000 +0200
*************** dequeue_and_dump (dump_info_p di)
*** 571,577 ****
      case TRUTH_NOT_EXPR:
      case ADDR_EXPR:
      case INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
      case CLEANUP_POINT_EXPR:
      case SAVE_EXPR:
--- 571,576 ----
Index: gcc/tree-pretty-print.c
===================================================================
*** gcc/tree-pretty-print.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-pretty-print.c	2010-07-02 14:30:00.000000000 +0200
*************** dump_generic_node (pretty_printer *buffe
*** 1586,1592 ****
      case ADDR_EXPR:
      case PREDECREMENT_EXPR:
      case PREINCREMENT_EXPR:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
      case INDIRECT_REF:
        if (TREE_CODE (node) == ADDR_EXPR
--- 1586,1591 ----
*************** op_code_prio (enum tree_code code)
*** 2549,2555 ****
      case PREINCREMENT_EXPR:
      case PREDECREMENT_EXPR:
      case NEGATE_EXPR:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
      case INDIRECT_REF:
      case ADDR_EXPR:
--- 2548,2553 ----
*************** op_symbol_code (enum tree_code code)
*** 2720,2728 ****
      case INDIRECT_REF:
        return "*";
  
-     case ALIGN_INDIRECT_REF:
-       return "A*";
- 
      case MISALIGNED_INDIRECT_REF:
        return "M*";
  
--- 2718,2723 ----
Index: gcc/tree.c
===================================================================
*** gcc/tree.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree.c	2010-07-02 14:30:00.000000000 +0200
*************** staticp (tree arg)
*** 2432,2438 ****
        return NULL;
  
      case MISALIGNED_INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case INDIRECT_REF:
        return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL;
  
--- 2432,2437 ----
*************** build1_stat (enum tree_code code, tree t
*** 3660,3666 ****
        break;
  
      case MISALIGNED_INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case INDIRECT_REF:
        /* Whether a dereference is readonly has nothing to do with whether
  	 its operand is readonly.  */
--- 3659,3664 ----
Index: gcc/tree.h
===================================================================
*** gcc/tree.h.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree.h	2010-07-02 14:30:00.000000000 +0200
*************** extern const enum tree_code_class tree_c
*** 118,124 ****
  
  #define INDIRECT_REF_P(CODE)\
    (TREE_CODE (CODE) == INDIRECT_REF \
-    || TREE_CODE (CODE) == ALIGN_INDIRECT_REF \
     || TREE_CODE (CODE) == MISALIGNED_INDIRECT_REF)
  
  /* Nonzero if CODE represents a reference.  */
--- 118,123 ----
*************** extern void omp_clause_range_check_faile
*** 1251,1257 ****
     accessing the memory pointed to won't generate a trap.  However,
     this only applies to an object when used appropriately: it doesn't
     mean that writing a READONLY mem won't trap. Similarly for
!    ALIGN_INDIRECT_REF and MISALIGNED_INDIRECT_REF.
  
     In ARRAY_REF and ARRAY_RANGE_REF means that we know that the index
     (or slice of the array) always belongs to the range of the array.
--- 1250,1256 ----
     accessing the memory pointed to won't generate a trap.  However,
     this only applies to an object when used appropriately: it doesn't
     mean that writing a READONLY mem won't trap. Similarly for
!    MISALIGNED_INDIRECT_REF.
  
     In ARRAY_REF and ARRAY_RANGE_REF means that we know that the index
     (or slice of the array) always belongs to the range of the array.
Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/fold-const.c	2010-07-02 14:30:00.000000000 +0200
*************** maybe_lvalue_p (const_tree x)
*** 2041,2048 ****
    case SSA_NAME:
  
    case COMPONENT_REF:
    case INDIRECT_REF:
-   case ALIGN_INDIRECT_REF:
    case MISALIGNED_INDIRECT_REF:
    case ARRAY_REF:
    case ARRAY_RANGE_REF:
--- 2041,2048 ----
    case SSA_NAME:
  
    case COMPONENT_REF:
+   case MEM_REF:
    case INDIRECT_REF:
    case MISALIGNED_INDIRECT_REF:
    case ARRAY_REF:
    case ARRAY_RANGE_REF:
*************** operand_equal_p (const_tree arg0, const_
*** 2586,2592 ****
        switch (TREE_CODE (arg0))
  	{
  	case INDIRECT_REF:
- 	case ALIGN_INDIRECT_REF:
  	case MISALIGNED_INDIRECT_REF:
  	case REALPART_EXPR:
  	case IMAGPART_EXPR:
--- 2586,2591 ----
*************** build_fold_addr_expr_with_type_loc (loca
*** 7596,7602 ****
    if (TREE_CODE (t) == WITH_SIZE_EXPR)
      t = TREE_OPERAND (t, 0);
  
-   /* Note: doesn't apply to ALIGN_INDIRECT_REF */
    if (TREE_CODE (t) == INDIRECT_REF
        || TREE_CODE (t) == MISALIGNED_INDIRECT_REF)
      {
--- 7595,7600 ----
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-ssa-sccvn.c	2010-07-02 14:30:00.000000000 +0200
*************** copy_reference_ops_from_ref (tree ref, V
*** 600,609 ****
  
        switch (temp.opcode)
  	{
- 	case ALIGN_INDIRECT_REF:
- 	  /* The only operand is the address, which gets its own
- 	     vn_reference_op_s structure.  */
- 	  break;
  	case MISALIGNED_INDIRECT_REF:
  	  temp.op0 = TREE_OPERAND (ref, 1);
  	  break;
--- 600,605 ----
*************** ao_ref_init_from_vn_reference (ao_ref *r
*** 789,799 ****
  	  return false;
  
  	/* Record the base objects.  */
- 	case ALIGN_INDIRECT_REF:
- 	  *op0_p = build1 (op->opcode, op->type, NULL_TREE);
- 	  op0_p = &TREE_OPERAND (*op0_p, 0);
- 	  break;
- 
  	case MISALIGNED_INDIRECT_REF:
  	  *op0_p = build2 (MISALIGNED_INDIRECT_REF, op->type,
  			   NULL_TREE, op->op0);
--- 785,790 ----
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
*** gcc/tree-ssa-loop-ivopts.c.orig	2010-07-02 14:16:20.000000000 +0200
--- gcc/tree-ssa-loop-ivopts.c	2010-07-02 14:30:00.000000000 +0200
*************** idx_find_step (tree base, tree *idx, voi
*** 1359,1366 ****
    tree step, iv_base, iv_step, lbound, off;
    struct loop *loop = dta->ivopts_data->current_loop;
  
!   if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF
!       || TREE_CODE (base) == ALIGN_INDIRECT_REF)
      return false;
  
    /* If base is a component ref, require that the offset of the reference
--- 1359,1365 ----
    tree step, iv_base, iv_step, lbound, off;
    struct loop *loop = dta->ivopts_data->current_loop;
  
!   if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF)
      return false;
  
    /* If base is a component ref, require that the offset of the reference
*************** find_interesting_uses_address (struct iv
*** 1672,1678 ****
  	goto fail;
        step = ifs_ivopts_data.step;
  
-       gcc_assert (TREE_CODE (base) != ALIGN_INDIRECT_REF);
        gcc_assert (TREE_CODE (base) != MISALIGNED_INDIRECT_REF);
  
        /* Check that the base expression is addressable.  This needs
--- 1671,1676 ----
Index: gcc/dwarf2out.c
===================================================================
*** gcc/dwarf2out.c.orig	2010-07-01 13:42:41.000000000 +0200
--- gcc/dwarf2out.c	2010-07-02 14:30:00.000000000 +0200
*************** loc_list_from_tree (tree loc, int want_a
*** 15186,15192 ****
  	return 0;
        /* Fallthru.  */
      case INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
        list_ret = loc_list_from_tree (TREE_OPERAND (loc, 0), 0);
        have_address = 1;
--- 15186,15191 ----
Index: gcc/expr.c
===================================================================
*** gcc/expr.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/expr.c	2010-07-02 14:30:00.000000000 +0200
*************** safe_from_p (const_rtx x, tree exp, int
*** 6703,6709 ****
  	  break;
  
  	case MISALIGNED_INDIRECT_REF:
- 	case ALIGN_INDIRECT_REF:
  	case INDIRECT_REF:
  	  if (MEM_P (x)
  	      && alias_sets_conflict_p (MEM_ALIAS_SET (x),
--- 6703,6708 ----
*************** expand_expr_real_1 (tree exp, rtx target
*** 8679,8690 ****
        return expand_constructor (exp, target, modifier, false);
  
      case MISALIGNED_INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case INDIRECT_REF:
        {
  	tree exp1 = treeop0;
  	addr_space_t as = ADDR_SPACE_GENERIC;
- 	enum machine_mode address_mode = Pmode;
  
  	if (modifier != EXPAND_WRITE)
  	  {
--- 8678,8687 ----
*************** expand_expr_real_1 (tree exp, rtx target
*** 8696,8716 ****
  	  }
  
  	if (POINTER_TYPE_P (TREE_TYPE (exp1)))
! 	  {
! 	    as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp1)));
! 	    address_mode = targetm.addr_space.address_mode (as);
! 	  }
  
  	op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM);
  	op0 = memory_address_addr_space (mode, op0, as);
  
- 	if (code == ALIGN_INDIRECT_REF)
- 	  {
- 	    int align = TYPE_ALIGN_UNIT (type);
- 	    op0 = gen_rtx_AND (address_mode, op0, GEN_INT (-align));
- 	    op0 = memory_address_addr_space (mode, op0, as);
- 	  }
- 
  	temp = gen_rtx_MEM (mode, op0);
  
  	set_mem_attributes (temp, exp, 0);
--- 8693,8703 ----
  	  }
  
  	if (POINTER_TYPE_P (TREE_TYPE (exp1)))
! 	  as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp1)));
  
  	op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM);
  	op0 = memory_address_addr_space (mode, op0, as);
  
  	temp = gen_rtx_MEM (mode, op0);
  
  	set_mem_attributes (temp, exp, 0);
*************** expand_expr_real_1 (tree exp, rtx target
*** 8775,8780 ****
--- 8762,8768 ----
  	  = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 1))));
  	enum machine_mode address_mode;
  	tree base = TREE_OPERAND (exp, 0);
+ 	gimple def_stmt;
  	/* Handle expansion of non-aliased memory with non-BLKmode.  That
  	   might end up in a register.  */
  	if (TREE_CODE (base) == ADDR_EXPR)
*************** expand_expr_real_1 (tree exp, rtx target
*** 8817,8824 ****
  	      }
  	  }
  	address_mode = targetm.addr_space.address_mode (as);
! 	op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, address_mode,
! 			   EXPAND_NORMAL);
  	if (!integer_zerop (TREE_OPERAND (exp, 1)))
  	  {
  	    rtx off;
--- 8805,8816 ----
  	      }
  	  }
  	address_mode = targetm.addr_space.address_mode (as);
! 	base = TREE_OPERAND (exp, 0);
! 	if ((def_stmt = get_def_for_expr (base, BIT_AND_EXPR)))
! 	  base = build2 (BIT_AND_EXPR, TREE_TYPE (base),
! 			 gimple_assign_rhs1 (def_stmt),
! 			 gimple_assign_rhs2 (def_stmt));
! 	op0 = expand_expr (base, NULL_RTX, address_mode, EXPAND_NORMAL);
  	if (!integer_zerop (TREE_OPERAND (exp, 1)))
  	  {
  	    rtx off;
Index: gcc/tree-eh.c
===================================================================
*** gcc/tree-eh.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-eh.c	2010-07-02 14:30:00.000000000 +0200
*************** tree_could_trap_p (tree expr)
*** 2442,2448 ****
  	return false;
        /* Fallthru.  */
      case INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
        return !TREE_THIS_NOTRAP (expr);
  
--- 2442,2447 ----
Index: gcc/tree-vect-data-refs.c
===================================================================
*** gcc/tree-vect-data-refs.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-vect-data-refs.c	2010-07-02 14:31:02.000000000 +0200
*************** vect_setup_realignment (gimple stmt, gim
*** 3178,3184 ****
        vec_dest = vect_create_destination_var (scalar_dest, vectype);
        ptr = vect_create_data_ref_ptr (stmt, loop_for_initial_load, NULL_TREE,
  				      &init_addr, &inc, true, &inv_p);
!       data_ref = build1 (ALIGN_INDIRECT_REF, vectype, ptr);
        new_stmt = gimple_build_assign (vec_dest, data_ref);
        new_temp = make_ssa_name (vec_dest, new_stmt);
        gimple_assign_set_lhs (new_stmt, new_temp);
--- 3178,3192 ----
        vec_dest = vect_create_destination_var (scalar_dest, vectype);
        ptr = vect_create_data_ref_ptr (stmt, loop_for_initial_load, NULL_TREE,
  				      &init_addr, &inc, true, &inv_p);
!       new_stmt = gimple_build_assign_with_ops
! 		   (BIT_AND_EXPR, NULL_TREE, ptr,
! 		    build_int_cst (TREE_TYPE (ptr),
! 				   -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
!       new_temp = make_ssa_name (SSA_NAME_VAR (ptr), new_stmt);
!       gimple_assign_set_lhs (new_stmt, new_temp);
!       new_bb = gsi_insert_on_edge_immediate (pe, new_stmt);
!       gcc_assert (!new_bb);
!       data_ref = build_simple_mem_ref (new_temp);
        new_stmt = gimple_build_assign (vec_dest, data_ref);
        new_temp = make_ssa_name (vec_dest, new_stmt);
        gimple_assign_set_lhs (new_stmt, new_temp);
Index: gcc/gimplify.c
===================================================================
*** gcc/gimplify.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/gimplify.c	2010-07-02 14:30:00.000000000 +0200
*************** gimplify_expr (tree *expr_p, gimple_seq
*** 6772,6778 ****
  	  recalculate_side_effects (*expr_p);
  	  break;
  
- 	case ALIGN_INDIRECT_REF:
  	case MISALIGNED_INDIRECT_REF:
  	  /* We can only reach this through re-gimplification from
  	     tree optimizers.  */
--- 6772,6777 ----
Index: gcc/tree.def
===================================================================
*** gcc/tree.def.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree.def	2010-07-02 14:30:00.000000000 +0200
*************** DEFTREECODE (ARRAY_RANGE_REF, "array_ran
*** 416,430 ****
  
  /* The ordering of the following codes is optimized for the checking
     macros in tree.h.  Changing the order will degrade the speed of the
!    compiler.  INDIRECT_REF, ALIGN_INDIRECT_REF, MISALIGNED_INDIRECT_REF.  */
  
  /* C unary `*' or Pascal `^'.  One operand, an expression for a pointer.  */
  DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1)
  
- /* Like above, but aligns the referenced address (i.e, if the address
-    in P is not aligned on TYPE_ALIGN boundary, then &(*P) != P).  */
- DEFTREECODE (ALIGN_INDIRECT_REF, "align_indirect_ref", tcc_reference, 1)
- 
  /* Same as INDIRECT_REF, but also specifies the alignment of the referenced
     address:
     Operand 0 is the referenced address (a pointer);
--- 416,426 ----
  
  /* The ordering of the following codes is optimized for the checking
     macros in tree.h.  Changing the order will degrade the speed of the
!    compiler.  INDIRECT_REF, MISALIGNED_INDIRECT_REF.  */
  
  /* C unary `*' or Pascal `^'.  One operand, an expression for a pointer.  */
  DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1)
  
  /* Same as INDIRECT_REF, but also specifies the alignment of the referenced
     address:
     Operand 0 is the referenced address (a pointer);
Index: gcc/emit-rtl.c
===================================================================
*** gcc/emit-rtl.c.orig	2010-07-01 11:39:42.000000000 +0200
--- gcc/emit-rtl.c	2010-07-02 14:30:00.000000000 +0200
*************** set_mem_attributes_minus_bitpos (rtx ref
*** 1611,1617 ****
    /* We can set the alignment from the type if we are making an object,
       this is an INDIRECT_REF, or if TYPE_ALIGN_OK.  */
    if (objectp || TREE_CODE (t) == INDIRECT_REF
-       || TREE_CODE (t) == ALIGN_INDIRECT_REF
        || TYPE_ALIGN_OK (type))
      align = MAX (align, TYPE_ALIGN (type));
    else if (TREE_CODE (t) == MEM_REF)
--- 1611,1616 ----
*************** set_mem_attributes_minus_bitpos (rtx ref
*** 1842,1855 ****
  	size = plus_constant (size, apply_bitpos / BITS_PER_UNIT);
      }
  
-   if (TREE_CODE (t) == ALIGN_INDIRECT_REF)
-     {
-       /* Force EXPR and OFFSET to NULL, since we don't know exactly what
- 	 we're overlapping.  */
-       offset = NULL;
-       expr = NULL;
-     }
- 
    /* Now set the attributes we computed above.  */
    MEM_ATTRS (ref)
      = get_mem_attrs (alias, expr, offset, size, align,
--- 1841,1846 ----
Index: gcc/cfgexpand.c
===================================================================
*** gcc/cfgexpand.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/cfgexpand.c	2010-07-02 14:30:00.000000000 +0200
*************** expand_debug_expr (tree exp)
*** 2239,2245 ****
    enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
    int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp));
    addr_space_t as;
-   enum machine_mode address_mode;
  
    switch (TREE_CODE_CLASS (TREE_CODE (exp)))
      {
--- 2239,2244 ----
*************** expand_debug_expr (tree exp)
*** 2444,2471 ****
  	return NULL;
        /* Fallthru.  */
      case INDIRECT_REF:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
        op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
        if (!op0)
  	return NULL;
  
        if (POINTER_TYPE_P (TREE_TYPE (exp)))
! 	{
! 	  as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
! 	  address_mode = targetm.addr_space.address_mode (as);
! 	}
        else
! 	{
! 	  as = ADDR_SPACE_GENERIC;
! 	  address_mode = Pmode;
! 	}
! 
!       if (TREE_CODE (exp) == ALIGN_INDIRECT_REF)
! 	{
! 	  int align = TYPE_ALIGN_UNIT (TREE_TYPE (exp));
! 	  op0 = gen_rtx_AND (address_mode, op0, GEN_INT (-align));
! 	}
  
        op0 = gen_rtx_MEM (mode, op0);
  
--- 2443,2457 ----
  	return NULL;
        /* Fallthru.  */
      case INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
        op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
        if (!op0)
  	return NULL;
  
        if (POINTER_TYPE_P (TREE_TYPE (exp)))
! 	as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
        else
! 	as = ADDR_SPACE_GENERIC;
  
        op0 = gen_rtx_MEM (mode, op0);
  
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-ssa-pre.c	2010-07-02 14:30:00.000000000 +0200
*************** create_component_ref_by_pieces_1 (basic_
*** 2820,2826 ****
  	return folded;
        }
        break;
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
        {
  	tree folded;
--- 2820,2825 ----
Index: gcc/tree-ssa-loop-prefetch.c
===================================================================
*** gcc/tree-ssa-loop-prefetch.c.orig	2010-06-15 11:12:00.000000000 +0200
--- gcc/tree-ssa-loop-prefetch.c	2010-07-02 14:30:00.000000000 +0200
*************** idx_analyze_ref (tree base, tree *index,
*** 404,411 ****
    HOST_WIDE_INT idelta = 0, imult = 1;
    affine_iv iv;
  
!   if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF
!       || TREE_CODE (base) == ALIGN_INDIRECT_REF)
      return false;
  
    if (!simple_iv (ar_data->loop, loop_containing_stmt (ar_data->stmt),
--- 404,410 ----
    HOST_WIDE_INT idelta = 0, imult = 1;
    affine_iv iv;
  
!   if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF)
      return false;
  
    if (!simple_iv (ar_data->loop, loop_containing_stmt (ar_data->stmt),
Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-vect-stmts.c	2010-07-02 14:39:16.000000000 +0200
*************** vectorizable_load (gimple stmt, gimple_s
*** 3684,3690 ****
  						dr_explicit_realign,
  						dataref_ptr, NULL);
  
! 		data_ref = build1 (ALIGN_INDIRECT_REF, vectype, dataref_ptr);
  		vec_dest = vect_create_destination_var (scalar_dest, vectype);
  		new_stmt = gimple_build_assign (vec_dest, data_ref);
  		new_temp = make_ssa_name (vec_dest, new_stmt);
--- 3684,3698 ----
  						dr_explicit_realign,
  						dataref_ptr, NULL);
  
! 		new_stmt = gimple_build_assign_with_ops
! 			     (BIT_AND_EXPR, NULL_TREE, dataref_ptr,
! 			      build_int_cst
! 			        (TREE_TYPE (dataref_ptr),
! 				 -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
! 		ptr = make_ssa_name (SSA_NAME_VAR (dataref_ptr), new_stmt);
! 		gimple_assign_set_lhs (new_stmt, ptr);
! 		vect_finish_stmt_generation (stmt, new_stmt, gsi);
! 		data_ref = build_simple_mem_ref (ptr);
  		vec_dest = vect_create_destination_var (scalar_dest, vectype);
  		new_stmt = gimple_build_assign (vec_dest, data_ref);
  		new_temp = make_ssa_name (vec_dest, new_stmt);
*************** vectorizable_load (gimple stmt, gimple_s
*** 3697,3707 ****
  		bump = size_binop (MULT_EXPR, vs_minus_1,
  				   TYPE_SIZE_UNIT (scalar_type));
  		ptr = bump_vector_ptr (dataref_ptr, NULL, gsi, stmt, bump);
! 	        data_ref = build1 (ALIGN_INDIRECT_REF, vectype, ptr);
  	        break;
  	      }
  	    case dr_explicit_realign_optimized:
! 	      data_ref = build1 (ALIGN_INDIRECT_REF, vectype, dataref_ptr);
  	      break;
  	    default:
  	      gcc_unreachable ();
--- 3705,3731 ----
  		bump = size_binop (MULT_EXPR, vs_minus_1,
  				   TYPE_SIZE_UNIT (scalar_type));
  		ptr = bump_vector_ptr (dataref_ptr, NULL, gsi, stmt, bump);
! 		new_stmt = gimple_build_assign_with_ops
! 			     (BIT_AND_EXPR, NULL_TREE, ptr,
! 			      build_int_cst
! 			        (TREE_TYPE (ptr),
! 				 -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
! 		ptr = make_ssa_name (SSA_NAME_VAR (dataref_ptr), new_stmt);
! 		gimple_assign_set_lhs (new_stmt, ptr);
! 		vect_finish_stmt_generation (stmt, new_stmt, gsi);
! 	        data_ref = build_simple_mem_ref (ptr);
  	        break;
  	      }
  	    case dr_explicit_realign_optimized:
! 	      new_stmt = gimple_build_assign_with_ops
! 			   (BIT_AND_EXPR, NULL_TREE, dataref_ptr,
! 			    build_int_cst
! 			      (TREE_TYPE (dataref_ptr),
! 			       -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
! 	      new_temp = make_ssa_name (SSA_NAME_VAR (dataref_ptr), new_stmt);
! 	      gimple_assign_set_lhs (new_stmt, new_temp);
! 	      vect_finish_stmt_generation (stmt, new_stmt, gsi);
! 	      data_ref = build_simple_mem_ref (new_temp);
  	      break;
  	    default:
  	      gcc_unreachable ();
Index: gcc/tree-cfg.c
===================================================================
*** gcc/tree-cfg.c.orig	2010-07-02 11:52:06.000000000 +0200
--- gcc/tree-cfg.c	2010-07-02 14:30:00.000000000 +0200
*************** verify_types_in_gimple_min_lval (tree ex
*** 2850,2857 ****
    if (is_gimple_id (expr))
      return false;
  
!   if (TREE_CODE (expr) != ALIGN_INDIRECT_REF
!       && TREE_CODE (expr) != MISALIGNED_INDIRECT_REF
        && TREE_CODE (expr) != TARGET_MEM_REF
        && TREE_CODE (expr) != MEM_REF)
      {
--- 2850,2856 ----
    if (is_gimple_id (expr))
      return false;
  
!   if (TREE_CODE (expr) != MISALIGNED_INDIRECT_REF
        && TREE_CODE (expr) != TARGET_MEM_REF
        && TREE_CODE (expr) != MEM_REF)
      {
*************** verify_gimple_assign_single (gimple stmt
*** 3702,3708 ****
  
      case COMPONENT_REF:
      case BIT_FIELD_REF:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
      case ARRAY_REF:
      case ARRAY_RANGE_REF:
--- 3701,3706 ----
Index: gcc/config/rs6000/rs6000.c
===================================================================
*** gcc/config/rs6000/rs6000.c.orig	2010-07-02 14:29:08.000000000 +0200
--- gcc/config/rs6000/rs6000.c	2010-07-02 14:30:00.000000000 +0200
*************** rs6000_check_sdmode (tree *tp, int *walk
*** 13694,13700 ****
      case SSA_NAME:
      case REAL_CST:
      case MEM_REF:
-     case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
      case VIEW_CONVERT_EXPR:
        if (TYPE_MODE (TREE_TYPE (*tp)) == SDmode)
--- 13694,13699 ----
Index: gcc/tree-ssa-operands.c
===================================================================
*** gcc/tree-ssa-operands.c.orig	2010-07-01 10:55:10.000000000 +0200
--- gcc/tree-ssa-operands.c	2010-07-02 14:30:00.000000000 +0200
*************** mark_address_taken (tree ref)
*** 712,718 ****
  
  
  /* A subroutine of get_expr_operands to handle MEM_REF,
!    ALIGN_INDIRECT_REF and MISALIGNED_INDIRECT_REF.
  
     STMT is the statement being processed, EXPR is the MEM_REF
        that got us here.
--- 712,718 ----
  
  
  /* A subroutine of get_expr_operands to handle MEM_REF,
!    MISALIGNED_INDIRECT_REF.
  
     STMT is the statement being processed, EXPR is the MEM_REF
        that got us here.
*************** get_expr_operands (gimple stmt, tree *ex
*** 914,920 ****
        get_expr_operands (stmt, &TREE_OPERAND (expr, 1), flags);
        /* fall through */
  
-     case ALIGN_INDIRECT_REF:
      case MEM_REF:
        get_indirect_ref_operands (stmt, expr, flags, true);
        return;
--- 914,919 ----

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Remove ALIGN_INDIRECT_REF
  2010-07-02 12:51 [PATCH] Remove ALIGN_INDIRECT_REF Richard Guenther
@ 2010-07-05 12:26 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2010-07-05 12:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: irar

On Fri, 2 Jul 2010, Richard Guenther wrote:

> 
> This patch removes ALIGN_INDIRECT_REF from the compiler and instead
> represents it as a combination of a BIT_AND_EXPR for pointer re-alignment
> and a MEM_REF operation.  This allows all analysis pieces that can
> deal with MEM_REF (or formerly INDIRECT_REF) also deal with
> ALIGN_INDIRECT_REF.  Especially alias information will be available
> on the RTL side.
> 
> I am in the process of re-bootstrapping and testing the patch on
> powerpc64-linux and plan to commit it on Monday if that worked out.

Committed as rev. 161830.

Richard.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-05 12:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-02 12:51 [PATCH] Remove ALIGN_INDIRECT_REF Richard Guenther
2010-07-05 12:26 ` 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).