On 04/16/2015 02:43 AM, Thomas Preud'homme wrote:
From: Jeff Law [mailto:l...@redhat.com]
Sent: Monday, April 13, 2015 8:48 PM

I know there were several followups between Steven and yourself.
With
stage1 now open, can you post a final version and do a final
bootstrap/test with it?

Here is what came out of our discussion with Steven:

The RTL cprop pass in GCC operates by doing a local constant/copy propagation
first and then a global one. In the local one, if a constant cannot be 
propagated
(eg. due to constraints of the destination instruction) a copy propagation is
done instead. However, at the global level copy propagation is only tried if no
constant can be propagated, ie. if a constant can be propagated but the
constraints of the destination instruction forbids it, no copy propagation will 
be
tried. This patch fixes this issue.

ChangeLog entries are as follows:

*** gcc/ChangeLog ***

2015-04-15  Thomas Preud'homme  <thomas.preudho...@arm.com>
                         Steven Bosscher <stevenb....@gmail.com>

         * cprop.c (cprop_reg_p): New.
         (hash_scan_set): Use above function to check if register can be
         propagated.
         (find_avail_set): Return up to two sets, one whose source is
         a register and one whose source is a constant.  Sets are returned in
         an array passed as parameter rather than as a return value.
         (cprop_insn): Use a do while loop rather than a goto.  Try each of the
         sets returned by find_avail_set, starting with the one whose source is
         a constant. Use cprop_reg_p to check if register can be propagated.
         (do_local_cprop): Use cprop_reg_p to check if register can be
         propagated.
         (implicit_set_cond_p): Likewise.

*** gcc/testsuite/ChangeLog ***

2015-04-15  Thomas Preud'homme  <thomas.preudho...@arm.com>
                         Steven Bosscher <stevenb....@gmail.com>

         * gcc.target/arm/pr64616.c: New file.


And the patch is:


diff --git a/gcc/cprop.c b/gcc/cprop.c
index c9fb2fc..78541cf 100644
--- a/gcc/cprop.c
+++ b/gcc/cprop.c
@@ -285,6 +285,15 @@ cprop_constant_p (const_rtx x)
    return CONSTANT_P (x) && (GET_CODE (x) != CONST || shared_const_p (x));
  }

+/* Determine whether the rtx X should be treated as a register that can
+   be propagated.  Any pseudo-register is fine.  */
+
+static bool
+cprop_reg_p (const_rtx x)
+{
+  return REG_P (x) && !HARD_REGISTER_P (x);
+}
How about instead this move to a more visible location (perhaps a macro in regs.h or an inline function). Then as a followup, change the various places that have this sequence to use that common definition that exist outside of cprop.c.

@@ -1191,7 +1192,7 @@ do_local_cprop (rtx x, rtx_insn *insn)
    /* Rule out USE instructions and ASM statements as we don't want to
       change the hard registers mentioned.  */
    if (REG_P (x)
-      && (REGNO (x) >= FIRST_PSEUDO_REGISTER
+      && (cprop_reg_p (x)
            || (GET_CODE (PATTERN (insn)) != USE
              && asm_noperands (PATTERN (insn)) < 0)))
Isn't the REG_P test now redundant?

OK for the trunk with those changes.

jeff

Reply via email to