[PATCH][alias-improvements] Fix issues with asms and TARGET_MEM_REFs

Richard Guenther rguenther@suse.de
Wed Dec 10 15:09:00 GMT 2008


For asms with "memory" clobber we forgot to add virtual operands.  For
TARGET_MEM_REFs we cannot apply TBAA disambiguation.

Bootstrapped/tested on x86_64-unknown-linux-gnu, applied to the branch.

Richard.

2008-12-10  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-operands.c (get_asm_expr_operands): Add proper
	virtual operands for memory clobbers.
	* tree-dfa.c (refs_may_alias_p): Disable TBAA disambiguation
	if one reference is a TARGET_MEM_REF.

Index: gcc/tree-ssa-operands.c
===================================================================
*** gcc/tree-ssa-operands.c	(revision 142591)
--- gcc/tree-ssa-operands.c	(working copy)
*************** get_asm_expr_operands (gimple stmt)
*** 1342,1364 ****
        tree link = gimple_asm_clobber_op (stmt, i);
        if (strcmp (TREE_STRING_POINTER (TREE_VALUE (link)), "memory") == 0)
  	{
! 	  unsigned i;
! 	  bitmap_iterator bi;
! 
! 	  /* Mark the statement as having memory operands.  */
! 	  gimple_set_references_memory (stmt, true);
! 
! 	  EXECUTE_IF_SET_IN_BITMAP (gimple_call_clobbered_vars (cfun), 0, i, bi)
! 	    {
! 	      tree var = referenced_var (i);
! 	      add_stmt_operand (&var, stmt, opf_def | opf_implicit);
! 	    }
! 
! 	  EXECUTE_IF_SET_IN_BITMAP (gimple_addressable_vars (cfun), 0, i, bi)
! 	    {
! 	      tree var = referenced_var (i);
! 	      add_stmt_operand (&var, stmt, opf_def | opf_implicit);
! 	    }
  	  break;
  	}
      }
--- 1342,1348 ----
        tree link = gimple_asm_clobber_op (stmt, i);
        if (strcmp (TREE_STRING_POINTER (TREE_VALUE (link)), "memory") == 0)
  	{
! 	  add_virtual_operand (stmt, opf_def);
  	  break;
  	}
      }
Index: gcc/tree-dfa.c
===================================================================
*** gcc/tree-dfa.c	(revision 142591)
--- gcc/tree-dfa.c	(working copy)
*************** refs_may_alias_p (tree ref1, tree ref2)
*** 975,984 ****
        return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
      }
  
!   /* If one base is a ref-all pointer weird things are allowed.  */
    strict_aliasing_applies = (flag_strict_aliasing
  			     && (!INDIRECT_REF_P (base1)
  				 || get_alias_set (base1) != 0)
  			     && (!INDIRECT_REF_P (base2)
  				 || get_alias_set (base2) != 0));
  
--- 975,987 ----
        return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
      }
  
!   /* If one base is a ref-all pointer or a TARGET_MEM_REF weird things
!      are allowed.  */
    strict_aliasing_applies = (flag_strict_aliasing
+ 			     && TREE_CODE (base1) != TARGET_MEM_REF
  			     && (!INDIRECT_REF_P (base1)
  				 || get_alias_set (base1) != 0)
+ 			     && TREE_CODE (base2) != TARGET_MEM_REF
  			     && (!INDIRECT_REF_P (base2)
  				 || get_alias_set (base2) != 0));
  



More information about the Gcc-patches mailing list