aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1995-12-27 15:25:35 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1995-12-27 15:25:35 -0500
commit8c87f107ff50fd839521ae057ee4f09d1f87feba (patch)
tree17a05e7405285b9216834c4e1a84e81c1a4f40ee
parent8e1e2862ad00842e7cd07d024e9044f0bdc7e6ee (diff)
downloadgcc-8c87f107ff50fd839521ae057ee4f09d1f87feba.zip
gcc-8c87f107ff50fd839521ae057ee4f09d1f87feba.tar.gz
gcc-8c87f107ff50fd839521ae057ee4f09d1f87feba.tar.bz2
(find_best_addr): Make sure folded address better before using.
From-SVN: r10873
-rw-r--r--gcc/cse.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/cse.c b/gcc/cse.c
index efd05de..fd086c5 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -2660,9 +2660,21 @@ find_best_addr (insn, loc)
sometimes simplify the expression. Many simplifications
will not be valid, but some, usually applying the associative rule, will
be valid and produce better code. */
- if (GET_CODE (addr) != REG
- && validate_change (insn, loc, fold_rtx (addr, insn), 0))
- addr = *loc;
+ if (GET_CODE (addr) != REG)
+ {
+ rtx folded = fold_rtx (copy_rtx (addr), NULL_RTX);
+
+ if (1
+#ifdef ADDRESS_COST
+ && (ADDRESS_COST (folded) < ADDRESS_COST (addr)
+ || (ADDRESS_COST (folded) == ADDRESS_COST (addr)
+ && rtx_cost (folded) > rtx_cost (addr)))
+#else
+ && rtx_cost (folded) < rtx_cost (addr)
+#endif
+ && validate_change (insn, loc, folded, 0))
+ addr = folded;
+ }
/* If this address is not in the hash table, we can't look for equivalences
of the whole address. Also, ignore if volatile. */