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]

[PATCH] jump threading does not work with ia32 new backend


Hi!

Jump threading doesn't apparently work with the new ia32 backend (and on
SPARC does not work either) while it used to work in old ia32 backend.
E.g.:
int a[2], b[1];

void foo(int x)
{
  if (x == 65535)
    {
      a[0] = 5;
      a[1] = 6;
    }
  if (x == 65535)
    {
      b[0] = 2;
    }
}

would check x == 65535 twice (while only once with 2.95.x).
The issue is that thread_jumps if it sees a hard register was modified does
not attempt anything and bails out.
This patch makes it to work (I tried to be conservative and do it for
MODE_CC only) by not handling a condition code register as modified if it
was set (as opposed to e.g. clobbered) between B1 and B2 conditional jumps.
The thread_jumps logic walks the insn chain backwards and bails out
if the condition code register is not set to the same value anyway, so it
will behave correctly.
Bootstrapped on i386-redhat-linux, no regressions.
Ok to commit?

2001-05-14  Jakub Jelinek  <jakub@redhat.com>

	* jump.c (mark_modified_reg): Allow jump threading if condition
	codes are represented by a hard register.

--- gcc/jump.c.jj	Thu May  3 20:03:09 2001
+++ gcc/jump.c	Mon May 14 14:53:29 2001
@@ -3762,7 +3762,7 @@ static int modified_mem;
 static void
 mark_modified_reg (dest, x, data)
      rtx dest;
-     rtx x ATTRIBUTE_UNUSED;
+     rtx x;
      void *data ATTRIBUTE_UNUSED;
 {
   int regno;
@@ -3780,7 +3780,13 @@ mark_modified_reg (dest, x, data)
   regno = REGNO (dest);
   if (regno >= FIRST_PSEUDO_REGISTER)
     modified_regs[regno] = 1;
-  else
+  /* Don't consider a hard condition code register as modified,
+     if it is being just set.  thread_jumps will check if it is set
+     to the same value.  */
+  else if (GET_MODE_CLASS (GET_MODE (dest)) != MODE_CC
+	   || GET_CODE (x) != SET
+	   || ! rtx_equal_p (dest, SET_DEST (x))
+	   || HARD_REGNO_NREGS (regno, GET_MODE (dest)) != 1)
     for (i = 0; i < HARD_REGNO_NREGS (regno, GET_MODE (dest)); i++)
       modified_regs[regno + i] = 1;
 }

	Jakub


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