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]

Fix minor bugs in expr.c


Tested on alphaev56-dec-osf4.0c.

Tue Nov 13 05:45:40 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* Makefile.in (expr.o): Depends on insn-attr.h.
	* expr.c (insn-attr.h): New include.
	(force_operand): If INSN_SCHEDULING, deal with paradoxical SUBREG
	of MEM.
	(highest_pow2_factor, case INTEGER_CST): Handle negative values.
	(expand_expr): Remove unneeded mark_temp_addr_taken calls and
	clean up related usage in ADDR_EXPR.
	(expand_expr_unaligned): Likewise.

*** Makefile.in	2001/11/13 05:49:50	1.777
--- Makefile.in	2001/11/13 10:26:30
*************** except.o : except.c $(CONFIG_H) $(SYSTEM
*** 1405,1411 ****
     dwarf2asm.h dwarf2out.h toplev.h $(HASHTAB_H) intl.h $(GGC_H)
  expr.o : expr.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h function.h \
!    $(REGS_H) $(EXPR_H) $(OPTABS_H) libfuncs.h insn-config.h $(RECOG_H) \
!    output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h except.h \
!    reload.h $(GGC_H) intl.h $(TM_P_H)
  builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
     $(TARGET_H) function.h $(REGS_H) $(EXPR_H) $(OPTABS_H) insn-config.h \
--- 1405,1411 ----
     dwarf2asm.h dwarf2out.h toplev.h $(HASHTAB_H) intl.h $(GGC_H)
  expr.o : expr.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h function.h \
!    $(REGS_H) $(EXPR_H) $(OPTABS_H) libfuncs.h insn-attr.h insn-config.h \
!    $(RECOG_H) output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h \
!    except.h reload.h $(GGC_H) intl.h $(TM_P_H)
  builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
     $(TARGET_H) function.h $(REGS_H) $(EXPR_H) $(OPTABS_H) insn-config.h \
*** expr.c	2001/11/11 11:02:25	1.374
--- expr.c	2001/11/13 10:27:22
*************** Software Foundation, 59 Temple Place - S
*** 32,35 ****
--- 32,36 ----
  #include "function.h"
  #include "insn-config.h"
+ #include "insn-attr.h"
  /* Include expr.h after insn-config.h so we get HAVE_conditional_move.  */
  #include "expr.h"
*************** force_operand (value, target)
*** 5654,5657 ****
--- 5655,5674 ----
  	 because the only operations we are expanding here are signed ones.  */
      }
+ 
+ #ifdef INSN_SCHEDULING
+   /* On machines that have insn scheduling, we want all memory reference to be
+      explicit, so we need to deal with such paradoxical SUBREGs.  */
+   if (GET_CODE (value) == SUBREG && GET_CODE (SUBREG_REG (value)) == MEM
+       && (GET_MODE_SIZE (GET_MODE (value))
+ 	  > GET_MODE_SIZE (GET_MODE (SUBREG_REG (value)))))
+     value
+       = simplify_gen_subreg (GET_MODE (value),
+ 			     force_reg (GET_MODE (SUBREG_REG (value)),
+ 					force_operand (SUBREG_REG (value),
+ 						       NULL_RTX)),
+ 			     GET_MODE (SUBREG_REG (value)),
+ 			     SUBREG_BYTE (value));
+ #endif
+ 
    return value;
  }
*************** highest_pow2_factor (exp)
*** 5983,5995 ****
      {
      case INTEGER_CST:
!       /* If the integer is expressable in a HOST_WIDE_INT, we can find
! 	 the lowest bit that's a one.  If the result is zero or negative,
! 	 pessimize by returning 1.  This is overly-conservative, but such
! 	 things should not happen in the offset expressions that we are
! 	 called with.  */
        if (host_integerp (exp, 0))
  	{
  	  c0 = tree_low_cst (exp, 0);
! 	  return c0 >= 0 ? c0 & -c0 : 1;
  	}
        break;
--- 6000,6012 ----
      {
      case INTEGER_CST:
!       /* If the integer is expressable in a HOST_WIDE_INT, we can find the
! 	 lowest bit that's a one.  If the result is zero, pessimize by
! 	 returning 1.  This is overly-conservative, but such things should not
! 	 happen in the offset expressions that we are called with.  */
        if (host_integerp (exp, 0))
  	{
  	  c0 = tree_low_cst (exp, 0);
! 	  c0 = c0 < 0 ? - c0 : c0;
! 	  return c0 != 0 ? c0 & -c0 : 1;
  	}
        break;
*************** expand_expr (exp, target, tmode, modifie
*** 7066,7070 ****
  		    rtx memloc = assign_temp (nt, 1, 1, 1);
  
- 		    mark_temp_addr_taken (memloc);
  		    emit_move_insn (memloc, op0);
  		    op0 = memloc;
--- 7083,7086 ----
*************** expand_expr (exp, target, tmode, modifie
*** 8620,8627 ****
  
      case ADDR_EXPR:
-       /* If nonzero, TEMP will be set to the address of something that might
- 	 be a MEM corresponding to a stack slot.  */
-       temp = 0;
- 
        /* Are we taking the address of a nested function?  */
        if (TREE_CODE (TREE_OPERAND (exp, 0)) == FUNCTION_DECL
--- 8636,8639 ----
*************** expand_expr (exp, target, tmode, modifie
*** 8671,8680 ****
  	    op0 = force_const_mem (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  				   op0);
- 	  else if (GET_CODE (op0) == MEM)
- 	    {
- 	      mark_temp_addr_taken (op0);
- 	      temp = XEXP (op0, 0);
- 	    }
- 
  	  else if (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG
  		   || GET_CODE (op0) == CONCAT || GET_CODE (op0) == ADDRESSOF
--- 8683,8686 ----
*************** expand_expr (exp, target, tmode, modifie
*** 8689,8693 ****
  	      rtx memloc = assign_temp (nt, 1, 1, 1);
  
- 	      mark_temp_addr_taken (memloc);
  	      if (GET_CODE (op0) == PARALLEL)
  		/* Handle calls that pass values in multiple non-contiguous
--- 8695,8698 ----
*************** expand_expr (exp, target, tmode, modifie
*** 8702,8714 ****
  	    abort ();
  
  	  if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  	    {
! 	      temp = XEXP (op0, 0);
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	      if (GET_MODE (temp) == Pmode && GET_MODE (temp) != mode
  		  && mode == ptr_mode)
! 		temp = convert_memory_address (ptr_mode, temp);
  #endif
! 	      return temp;
  	    }
  
--- 8708,8721 ----
  	    abort ();
  
+ 	  mark_temp_addr_taken (op0);
  	  if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
  	    {
! 	      op0 = XEXP (op0, 0);
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	      if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
  		  && mode == ptr_mode)
! 		op0 = convert_memory_address (ptr_mode, op0);
  #endif
! 	      return op0;
  	    }
  
*************** expand_expr (exp, target, tmode, modifie
*** 8723,8731 ****
  	mark_reg_pointer (op0, TYPE_ALIGN (TREE_TYPE (type)));
  
-       /* If we might have had a temp slot, add an equivalent address
- 	 for it.  */
-       if (temp != 0)
- 	update_temp_slot_address (temp, op0);
- 
  #ifdef POINTERS_EXTEND_UNSIGNED
        if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
--- 8730,8733 ----
*************** expand_expr_unaligned (exp, palign)
*** 9085,9089 ****
  		rtx memloc = assign_temp (nt, 1, 1, 1);
  
- 		mark_temp_addr_taken (memloc);
  		emit_move_insn (memloc, op0);
  		op0 = memloc;
--- 9087,9090 ----


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