]> gcc.gnu.org Git - gcc.git/commitdiff
expr.c (get_subtarget): New function.
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Sat, 6 May 2000 10:17:11 +0000 (10:17 +0000)
committerRichard Kenner <kenner@gcc.gnu.org>
Sat, 6 May 2000 10:17:11 +0000 (06:17 -0400)
* 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.

From-SVN: r33722

gcc/ChangeLog
gcc/expr.c
gcc/toplev.c

index 1c68b3e8843ae16fecacb4cdc7280d754771d085..58bb7a68bed2e2cae55866029552ff2a1a77b889 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2000-05-06  David Edelsohn  <edelsohn@gnu.org>
 
        * xcoffout.c (xcoff_current_include_file,
index b680ca8e1f78474c98b12604ec34fd78088f5774..a70545b2b03f3beddf96fdbee2dbfd23d2ffd1b6 100644 (file)
@@ -155,6 +155,7 @@ static void clear_by_pieces PARAMS ((rtx, int, unsigned int));
 static void clear_by_pieces_1  PARAMS ((rtx (*) (rtx, ...),
                                         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));
 static void store_constructor_field PARAMS ((rtx, unsigned HOST_WIDE_INT,
@@ -335,6 +336,7 @@ free_expr_status (f)
 }
 
 /* Small sanity check that the queue is empty at the end of a function.  */
+
 void
 finish_expr_for_function ()
 {
@@ -2177,7 +2179,6 @@ copy_blkmode_from_reg (tgtblk, srcreg, type)
   return tgtblk;
 }
 
-
 /* Add a USE expression for REG to the (possibly empty) list pointed
    to by CALL_FUSAGE.  REG must denote a hard register.  */
 
@@ -3324,6 +3325,26 @@ emit_push_insn (x, mode, type, size, align, partial, reg, extra,
     anti_adjust_stack (alignment_pad);
 }
 \f
+/* 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.
    (This may contain a QUEUED rtx;
@@ -5164,7 +5185,7 @@ force_operand (value, target)
   rtx tmp;
   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);
+  register rtx subtarget = get_subtarget (target);
 
   /* Check for a PIC address load.  */
   if (flag_pic
@@ -5707,7 +5728,7 @@ expand_expr (exp, target, tmode, modifier)
 
   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);
+  subtarget = get_subtarget (target);
   original_target = target;
   ignore = (target == const0_rtx
            || ((code == NON_LVALUE_EXPR || code == NOP_EXPR
@@ -5722,15 +5743,6 @@ expand_expr (exp, target, tmode, modifier)
   else
     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
      is, short-circuit the most common cases here.  Note that we must
@@ -10244,8 +10256,7 @@ do_store_flag (exp, target, mode, only_cheap)
 #endif
                       );
 
-      if (subtarget == 0 || GET_CODE (subtarget) != REG
-         || GET_MODE (subtarget) != operand_mode
+      if (! get_subtarget (subtarget)
          || ! safe_from_p (subtarget, inner, 1))
        subtarget = 0;
 
@@ -10295,8 +10306,7 @@ do_store_flag (exp, target, mode, only_cheap)
     }
       
   preexpand_calls (exp);
-  if (subtarget == 0 || GET_CODE (subtarget) != REG
-      || GET_MODE (subtarget) != operand_mode
+  if (! get_subtarget (target)
       || ! safe_from_p (subtarget, arg1, 1))
     subtarget = 0;
 
index 3050aace91b126ee0e3dd34a9f9e0143ece90c10..e780587e8ccc128037e17771561f6077ea593a83 100644 (file)
@@ -2124,8 +2124,9 @@ compile_file (name)
 #endif
     }
 
-  if (ggc_p)
+  if (ggc_p && name != 0)
     name = ggc_alloc_string (name, strlen (name));
+
   input_filename = name;
 
   /* Put an entry on the input file stack for the main input file.  */
This page took 0.09376 seconds and 5 git commands to generate.