]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cselib.c (expand_loc): Return sp, fp, hfp or cfa base reg right away if seen.
authorWei Guozhi <carrot@google.com>
Fri, 14 Sep 2012 23:00:45 +0000 (23:00 +0000)
committerWei Guozhi <carrot@gcc.gnu.org>
Fri, 14 Sep 2012 23:00:45 +0000 (23:00 +0000)
* cselib.c (expand_loc): Return sp, fp, hfp or cfa base reg right
away if seen.

From-SVN: r191315

gcc/ChangeLog
gcc/cselib.c

index 8ff1ac63ccc39a344a133421af8b7210982af94c..e381f2e8084946d0fa3e096c04de225b2a23e0dc 100644 (file)
@@ -1,3 +1,10 @@
+2012-09-14  Wei Guozhi  <carrot@google.com>
+
+       Backport from 2012-02-13 mainline r184169.
+
+       * cselib.c (expand_loc): Return sp, fp, hfp or cfa base reg right
+       away if seen.
+
 2012-09-10  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2012-09-10 mainline r191132.
index a2fdef7dbe3f8b105f885d46858ea2bde5b7069e..d060c274562ba608228a708aa78f891402ffb08a 100644 (file)
@@ -1237,8 +1237,18 @@ expand_loc (struct elt_loc_list *p, struct expand_value_data *evd,
   unsigned int regno = UINT_MAX;
   struct elt_loc_list *p_in = p;
 
-  for (; p; p = p -> next)
+  for (; p; p = p->next)
     {
+      /* Return these right away to avoid returning stack pointer based
+        expressions for frame pointer and vice versa, which is something
+        that would confuse DSE.  See the comment in cselib_expand_value_rtx_1
+        for more details.  */
+      if (REG_P (p->loc)
+         && (REGNO (p->loc) == STACK_POINTER_REGNUM
+             || REGNO (p->loc) == FRAME_POINTER_REGNUM
+             || REGNO (p->loc) == HARD_FRAME_POINTER_REGNUM
+             || REGNO (p->loc) == cfa_base_preserved_regno))
+       return p->loc;
       /* Avoid infinite recursion trying to expand a reg into a
         the same reg.  */
       if ((REG_P (p->loc))