]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[LRA]: Exclude reloading of frame pointer in subreg for some cases
authorVladimir N. Makarov <vmakarov@redhat.com>
Thu, 20 Jul 2023 18:34:26 +0000 (14:34 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Thu, 20 Jul 2023 18:42:58 +0000 (14:42 -0400)
LRA for avr port reloads frame pointer in subreg although we can just
simplify the subreg.  It results in generation of bad performance code.  The following
patch fixes this.

gcc/ChangeLog:

* lra-constraints.cc (simplify_operand_subreg): Check frame pointer
simplification.

gcc/lra-constraints.cc

index 76a155e99c24c32c566f89c183cb2f3d0d67ffc7..f3784cf5a5be8654fcf71a65673386f3c5117a48 100644 (file)
@@ -1797,6 +1797,16 @@ simplify_operand_subreg (int nop, machine_mode reg_mode)
       alter_subreg (curr_id->operand_loc[nop], false);
       return true;
     }
+  auto fp_subreg_can_be_simplified_after_reload_p = [] (machine_mode innermode,
+                                                       poly_uint64 offset,
+                                                       machine_mode mode) {
+    reload_completed = 1;
+    bool res = simplify_subreg_regno (FRAME_POINTER_REGNUM,
+                                     innermode,
+                                     offset, mode) >= 0;
+    reload_completed = 0;
+    return res;
+  };
   /* Force a reload of the SUBREG_REG if this is a constant or PLUS or
      if there may be a problem accessing OPERAND in the outer
      mode.  */
@@ -1809,6 +1819,12 @@ simplify_operand_subreg (int nop, machine_mode reg_mode)
           >= hard_regno_nregs (hard_regno, mode))
        && simplify_subreg_regno (hard_regno, innermode,
                                 SUBREG_BYTE (operand), mode) < 0
+       /* Exclude reloading of frame pointer in subreg if frame pointer can not
+         be simplified here only because the reload is not finished yet.  */
+       && (hard_regno != FRAME_POINTER_REGNUM
+          || !fp_subreg_can_be_simplified_after_reload_p (innermode,
+                                                          SUBREG_BYTE (operand),
+                                                          mode))
        /* Don't reload subreg for matching reload.  It is actually
          valid subreg in LRA.  */
        && ! LRA_SUBREG_P (operand))