This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Detect true-dependency for strict_low_part in scheduling


Currently 'sched_analyze_insn' does not detect a true dependency for
strict_low_part (also for zero/sign_extract and certain subregs). Only
a output_dependency is detected. This leads to suboptimal code regarding
scheduling.


Possible patch: (bootstrapped/regtested on s390x and i386)

      regards,
            Hartmut Penner

Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v
retrieving revision 1.54
diff -c -p -r1.54 sched-deps.c
*** sched-deps.c  28 Jan 2003 17:12:06 -0000    1.54
--- sched-deps.c  21 Feb 2003 08:23:29 -0000
*************** static void sched_analyze_insn PARAMS ((
*** 92,98 ****
--- 92,122 ----

  static rtx get_condition PARAMS ((rtx));
  static int conditions_mutex_p PARAMS ((rtx, rtx));
+ static inline bool read_modify_subreg_p PARAMS ((rtx));
+

+ /* Return non-zero if writes to paradoxical SUBREGs, or SUBREGs which
+    are too narrow, are read-modify-write.
+    Fixme: Duplicate to function in df.c !!! */
+
+ static inline bool
+ read_modify_subreg_p (x)
+      rtx x;
+ {
+   unsigned int isize, osize;
+   if (GET_CODE (x) != SUBREG)
+     return false;
+   isize = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
+   osize = GET_MODE_SIZE (GET_MODE (x));
+   if (isize <= osize)
+     return true;
+   if (isize <= UNITS_PER_WORD)
+     return false;
+   if (osize > UNITS_PER_WORD)
+     return false;
+   return true;
+ }
+
  /* Return nonzero if a load of the memory reference MEM can cause a trap.  */

  static int
*************** sched_analyze_1 (deps, x, insn)
*** 466,471 ****
--- 490,508 ----
    while (GET_CODE (dest) == STRICT_LOW_PART || GET_CODE (dest) == SUBREG
       || GET_CODE (dest) == ZERO_EXTRACT || GET_CODE (dest) == SIGN_EXTRACT)
      {
+       if (GET_CODE (dest) == STRICT_LOW_PART
+      || GET_CODE (dest) == ZERO_EXTRACT
+      || GET_CODE (dest) == SIGN_EXTRACT
+      || read_modify_subreg_p (dest))
+         {
+       /* These both read and modify the result.  We must handle
+              them as writes to get proper dependencies for following
+              instructions.  We must handle them as reads to get proper
+              dependencies from this to previous instructions.
+              Thus we need to call sched_analyze_2. */
+
+       sched_analyze_2 (deps, XEXP (dest, 0), insn);
+     }
        if (GET_CODE (dest) == ZERO_EXTRACT || GET_CODE (dest) == SIGN_EXTRACT)
      {
        /* The second and third arguments are values read by this insn.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]