[patch, commited] Avoid casts in arguments of TARGET_MEM_REF

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Sun Mar 4 16:21:00 GMT 2007


Hello,

when TARGET_MEM_REF is created and we find out that a link-time symbol
cannot appear in the address, such symbol is moved to base (where it is
expected to be loaded to a register first).  However, we introduce an
unnecessary cast in this step, which violates gimple operand syntax.
This causes a failure in loop-19.c test.  The patch makes us avoid
introducing this cast.

Bootstrapped & regtested on i686 and ppc-linux, commited.

Zdenek

	* tree-ssa-address.c (create_mem_ref): Do not put an expression
	containing a cast to the base of TARGET_MEM_REF.

Index: tree-ssa-address.c
===================================================================
*** tree-ssa-address.c	(revision 122524)
--- tree-ssa-address.c	(working copy)
*************** tree
*** 569,575 ****
  create_mem_ref (block_stmt_iterator *bsi, tree type, aff_tree *addr)
  {
    tree mem_ref, tmp;
!   tree addr_type = build_pointer_type (type), atype;
    struct mem_address parts;
  
    addr_to_parts (addr, &parts);
--- 569,575 ----
  create_mem_ref (block_stmt_iterator *bsi, tree type, aff_tree *addr)
  {
    tree mem_ref, tmp;
!   tree atype;
    struct mem_address parts;
  
    addr_to_parts (addr, &parts);
*************** create_mem_ref (block_stmt_iterator *bsi
*** 597,614 ****
  
    if (parts.symbol)
      {
!       tmp = fold_convert (addr_type,
! 			  build_addr (parts.symbol, current_function_decl));
      
        /* Add the symbol to base, eventually forcing it to register.  */
        if (parts.base)
  	{
  	  if (parts.index)
! 	    parts.base = force_gimple_operand_bsi (bsi,
! 			fold_build2 (PLUS_EXPR, addr_type,
! 				     fold_convert (addr_type, parts.base),
  				     tmp),
  			true, NULL_TREE);
  	  else
  	    {
  	      parts.index = parts.base;
--- 597,619 ----
  
    if (parts.symbol)
      {
!       tmp = build_addr (parts.symbol, current_function_decl);
!       gcc_assert (is_gimple_val (tmp));
      
        /* Add the symbol to base, eventually forcing it to register.  */
        if (parts.base)
  	{
+ 	  gcc_assert (TREE_TYPE (parts.base) == sizetype);
+ 
  	  if (parts.index)
! 	    {
! 	      atype = TREE_TYPE (tmp);
! 	      parts.base = force_gimple_operand_bsi (bsi,
! 			fold_build2 (PLUS_EXPR, atype,
! 				     fold_convert (atype, parts.base),
  				     tmp),
  			true, NULL_TREE);
+ 	    }
  	  else
  	    {
  	      parts.index = parts.base;



More information about the Gcc-patches mailing list