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]

Bug in expr.c and minor bug in toplev.c


These were tested on Alpha.

(1) You can't use a readonly pseudo as a subtarget because it will
get set more than one, in violation of what "readonly" means.
(2) If there's no filename, toplev.c blows up.

Sat May  6 06:25:56 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* expr.c (get_subtarget): New function.
	(force_operand, expand_expr, do_store_flag): Use it.

	* toplev.c (compile_file): Don't take strlen of NAME if null.

*** expr.c	2000/05/04 21:15:03	1.236
--- expr.c	2000/05/06 02:18:10
*************** static void clear_by_pieces_1	PARAMS ((r
*** 156,159 ****
--- 156,160 ----
  					 enum machine_mode,
  					 struct clear_by_pieces *));
+ static rtx get_subtarget	PARAMS ((rtx));
  static int is_zeros_p		PARAMS ((tree));
  static int mostly_zeros_p	PARAMS ((tree));
*************** free_expr_status (f)
*** 336,339 ****
--- 337,341 ----
  
  /* Small sanity check that the queue is empty at the end of a function.  */
+ 
  void
  finish_expr_for_function ()
*************** copy_blkmode_from_reg (tgtblk, srcreg, t
*** 2178,2182 ****
  }
  
- 
  /* Add a USE expression for REG to the (possibly empty) list pointed
     to by CALL_FUSAGE.  REG must denote a hard register.  */
--- 2180,2183 ----
*************** emit_push_insn (x, mode, type, size, ali
*** 3325,3328 ****
--- 3326,3349 ----
  }
  
+ /* Return X if X can be used as a subtarget in a sequence of arithmetic
+    operations.  */
+ 
+ static rtx
+ get_subtarget (x)
+      rtx x;
+ {
+   return ((x == 0
+ 	   /* Only registers can be subtargets.  */
+ 	   || GET_CODE (x) != REG
+ 	   /* If the register is readonly, it can't be set more than once.  */
+ 	   || RTX_UNCHANGING_P (x)
+ 	   /* Don't use hard regs to avoid extending their life.  */
+ 	   || REGNO (x) < FIRST_PSEUDO_REGISTER
+ 	   /* Avoid subtargets inside loops,
+ 	      since they hide some invariant expressions.  */
+ 	   || preserve_subexpressions_p ())
+ 	  ? 0 : x);
+ }
+ 
  /* Expand an assignment that stores the value of FROM into TO.
     If WANT_VALUE is nonzero, return an rtx for the value of TO.
*************** force_operand (value, target)
*** 5165,5169 ****
    register rtx op2;
    /* Use subtarget as the target for operand 0 of a binary operation.  */
!   register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  
    /* Check for a PIC address load.  */
--- 5186,5190 ----
    register rtx op2;
    /* Use subtarget as the target for operand 0 of a binary operation.  */
!   register rtx subtarget = get_subtarget (target);
  
    /* Check for a PIC address load.  */
*************** expand_expr (exp, target, tmode, modifie
*** 5708,5712 ****
    mode = TYPE_MODE (type);
    /* Use subtarget as the target for operand 0 of a binary operation.  */
!   subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
    original_target = target;
    ignore = (target == const0_rtx
--- 5729,5733 ----
    mode = TYPE_MODE (type);
    /* Use subtarget as the target for operand 0 of a binary operation.  */
!   subtarget = get_subtarget (target);
    original_target = target;
    ignore = (target == const0_rtx
*************** expand_expr (exp, target, tmode, modifie
*** 5723,5735 ****
      ro_modifier = EXPAND_NORMAL;
  
-   /* Don't use hard regs as subtargets, because the combiner
-      can only handle pseudo regs.  */
-   if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
-     subtarget = 0;
-   /* Avoid subtargets inside loops,
-      since they hide some invariant expressions.  */
-   if (preserve_subexpressions_p ())
-     subtarget = 0;
- 
    /* If we are going to ignore this result, we need only do something
       if there is a side-effect somewhere in the expression.  If there
--- 5744,5747 ----
*************** do_store_flag (exp, target, mode, only_c
*** 10245,10250 ****
  		       );
  
!       if (subtarget == 0 || GET_CODE (subtarget) != REG
! 	  || GET_MODE (subtarget) != operand_mode
  	  || ! safe_from_p (subtarget, inner, 1))
  	subtarget = 0;
--- 10257,10261 ----
  		       );
  
!       if (! get_subtarget (subtarget)
  	  || ! safe_from_p (subtarget, inner, 1))
  	subtarget = 0;
*************** do_store_flag (exp, target, mode, only_c
*** 10296,10301 ****
        
    preexpand_calls (exp);
!   if (subtarget == 0 || GET_CODE (subtarget) != REG
!       || GET_MODE (subtarget) != operand_mode
        || ! safe_from_p (subtarget, arg1, 1))
      subtarget = 0;
--- 10307,10311 ----
        
    preexpand_calls (exp);
!   if (! get_subtarget (target)
        || ! safe_from_p (subtarget, arg1, 1))
      subtarget = 0;
*** toplev.c	2000/05/02 20:43:23	1.330
--- toplev.c	2000/05/06 02:18:41
*************** compile_file (name)
*** 2129,2134 ****
      }
  
!   if (ggc_p)
      name = ggc_alloc_string (name, strlen (name));
    input_filename = name;
  
--- 2129,2135 ----
      }
  
!   if (ggc_p && name != 0)
      name = ggc_alloc_string (name, strlen (name));
+ 
    input_filename = name;
  

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