From 4b980e20ad0778782fdf76e58a71d4a88b5a3df0 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Sun, 28 Jun 1992 06:10:54 -0400 Subject: [PATCH] *** empty log message *** From-SVN: r1318 --- gcc/cse.c | 42 ++++++++++++++++++++++++++++++++++++++---- gcc/expmed.c | 6 ++++++ gcc/flow.c | 3 --- gcc/integrate.c | 2 -- gcc/loop.c | 2 -- gcc/reload1.c | 3 --- gcc/reorg.c | 3 --- gcc/rtl.c | 2 -- gcc/rtl.h | 2 ++ gcc/stmt.c | 3 --- gcc/toplev.c | 8 ++++---- gcc/tree.c | 3 --- gcc/tree.h | 2 ++ gcc/varasm.c | 1 - 14 files changed, 52 insertions(+), 30 deletions(-) diff --git a/gcc/cse.c b/gcc/cse.c index 6476549f1a6..334d899ef42 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -4327,10 +4327,32 @@ fold_rtx (x, insn) || (new = lookup_as_function (x, CONST_DOUBLE)) != 0) return new; - /* If this is a paradoxical SUBREG, we can't do anything with - it because we have no idea what value the extra bits would have. */ + /* If this is a paradoxical SUBREG, we have no idea what value the + extra bits would have. However, if the operand is equivalent + to a SUBREG whose operand is the same as our mode, and all the + modes are within a word, we can just use the inner operand + because these SUBREGs just say how to treat the register. */ + if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) - return x; + { + enum machine_mode imode = GET_MODE (SUBREG_REG (x)); + struct table_elt *elt; + + if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD + && GET_MODE_SIZE (imode) <= UNITS_PER_WORD + && (elt = lookup (SUBREG_REG (x), HASH (SUBREG_REG (x), imode), + imode)) != 0) + { + for (elt = elt->first_same_value; + elt; elt = elt->next_same_value) + if (GET_CODE (elt->exp) == SUBREG + && GET_MODE (SUBREG_REG (elt->exp)) == mode + && exp_equiv_p (elt->exp, elt->exp, 1)) + return copy_rtx (SUBREG_REG (elt->exp)); + } + + return x; + } /* Fold SUBREG_REG. If it changed, see if we can simplify the SUBREG. We might be able to if the SUBREG is extracting a single word in an @@ -4364,7 +4386,12 @@ fold_rtx (x, insn) extra bits will be. But we can find an equivalence for this SUBREG by folding that operation is the narrow mode. This allows us to fold arithmetic in narrow modes when the machine only supports - word-sized arithmetic. */ + word-sized arithmetic. + + Also look for a case where we have a SUBREG whose operand is the + same as our result. If both modes are smaller than a word, we + are simply interpreting a register in different modes and we + can use the inner value. */ if (GET_CODE (folded_arg0) == REG && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (folded_arg0))) @@ -4430,6 +4457,13 @@ fold_rtx (x, insn) op0, op1); } + else if (GET_CODE (elt->exp) == SUBREG + && GET_MODE (SUBREG_REG (elt->exp)) == mode + && (GET_MODE_SIZE (GET_MODE (folded_arg0)) + <= UNITS_PER_WORD) + && exp_equiv_p (elt->exp, elt->exp, 1)) + new = copy_rtx (SUBREG_REG (elt->exp)); + if (new) return new; } diff --git a/gcc/expmed.c b/gcc/expmed.c index 9d0962e6bcc..a251644669e 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -2782,6 +2782,12 @@ emit_store_flag (target, code, op0, op1, mode, unsignedp, normalizep) else op0 = subtarget; + /* If we want to keep subexpressions around, don't reuse our + last target. */ + + if (preserve_subexpressions_p ()) + subtarget = 0; + /* Now normalize to the proper value in COMPARE_MODE. Sometimes we don't have to do anything. */ if (normalizep == 0 || normalizep == STORE_FLAG_VALUE) diff --git a/gcc/flow.c b/gcc/flow.c index bc19c92dfe1..bc036dd15d8 100644 --- a/gcc/flow.c +++ b/gcc/flow.c @@ -121,9 +121,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free -extern int xmalloc (); -extern void free (); - /* List of labels that must never be deleted. */ extern rtx forced_labels; diff --git a/gcc/integrate.c b/gcc/integrate.c index 367d76f6310..31a62bea438 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -36,8 +36,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "obstack.h" #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free -extern int xmalloc (); -extern void free (); extern struct obstack *function_maybepermanent_obstack; diff --git a/gcc/loop.c b/gcc/loop.c index 237f43ca09f..13bdcd89609 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -193,8 +193,6 @@ extern struct obstack *rtl_obstack; #define obstack_chunk_free free extern char *oballoc (); -extern int xmalloc (); -extern void free (); /* During the analysis of a loop, a chain of `struct movable's is made to record all the movable insns found. diff --git a/gcc/reload1.c b/gcc/reload1.c index c68473dca58..26768dc7e2d 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -246,9 +246,6 @@ char *reload_firstobj; #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free -extern int xmalloc (); -extern void free (); - /* List of labels that must never be deleted. */ extern rtx forced_labels; diff --git a/gcc/reorg.c b/gcc/reorg.c index 6af7a9132f7..afdbb098063 100644 --- a/gcc/reorg.c +++ b/gcc/reorg.c @@ -129,9 +129,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free -extern int xmalloc (); -extern void free (); - #ifndef ANNUL_IFTRUE_SLOTS #define eligible_for_annul_true(INSN, SLOTS, TRIAL) 0 #endif diff --git a/gcc/rtl.c b/gcc/rtl.c index 04bc39c4093..c3f03575aee 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -26,8 +26,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "obstack.h" #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free -extern int xmalloc (); -extern void free (); /* Obstack used for allocating RTL objects. Between functions, this is the permanent_obstack. diff --git a/gcc/rtl.h b/gcc/rtl.h index a49029ed14a..923786f9942 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -526,6 +526,8 @@ extern char *note_insn_name[]; /* Generally useful functions. */ +extern char *xmalloc (); +extern void free (); extern rtx rtx_alloc (); extern rtvec rtvec_alloc (); extern rtx find_reg_note (); diff --git a/gcc/stmt.c b/gcc/stmt.c index 7abf935f407..a6d98e64f4d 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -54,9 +54,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define obstack_chunk_free free struct obstack stmt_obstack; -extern int xmalloc (); -extern void free (); - /* Filename and line number of last line-number note, whether we actually emitted it or not. */ char *emit_filename; diff --git a/gcc/toplev.c b/gcc/toplev.c index ad6e1e130d2..ab51d2f09c2 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1161,11 +1161,11 @@ botch (s) /* Same as `malloc' but report error if no memory available. */ -int +char * xmalloc (size) unsigned size; { - register int value = (int) malloc (size); + register char *value = (char *) malloc (size); if (value == 0) fatal ("virtual memory exhausted"); return value; @@ -1173,12 +1173,12 @@ xmalloc (size) /* Same as `realloc' but report error if no memory available. */ -int +char * xrealloc (ptr, size) char *ptr; int size; { - int result = realloc (ptr, size); + char *result = (char *) realloc (ptr, size); if (!result) fatal ("virtual memory exhausted"); return result; diff --git a/gcc/tree.c b/gcc/tree.c index a0ff3fefc1b..3d3149c0417 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -43,9 +43,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free -extern int xmalloc (); -extern void free (); - /* Tree nodes of permanent duration are allocated in this obstack. They are the identifier nodes, and everything outside of the bodies and parameters of function definitions. */ diff --git a/gcc/tree.h b/gcc/tree.h index 87effce790a..a64826c04a2 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -855,6 +855,8 @@ union tree_node extern char *oballoc (); extern char *permalloc (); extern char *savealloc (); +extern char *xmalloc (); +extern void free (); /* Lowest level primitive for allocating a node. The TREE_CODE is the only argument. Contents are initialized diff --git a/gcc/varasm.c b/gcc/varasm.c index 3e54ce8811d..6c25b9282b2 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -58,7 +58,6 @@ extern struct obstack *current_obstack; extern struct obstack *saveable_obstack; extern struct obstack permanent_obstack; #define obstack_chunk_alloc xmalloc -extern int xmalloc (); /* Number for making the label on the next constant that is stored in memory. */ -- 2.30.2