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]

[3.3 PATCH] fix PHI insertion for RTL SSA-CCP


Hello,

This is a fix for a part of GCC 3.3 based compiler that is
used probably by no-one at all.

Like I have nothing better to do...

But I wanted to see if RTL SSA really is as poor as everyone
always claims it to be, and I need it in more-or-less working
shape for that purpose (it now "only" fails with a bunch of
unrecognizable insns that all look alike -- it actually looks
like that may be a "real" bug...).

Anyway...

Given that nobody uses -fssa -fssa-ccp, one can either say that
this one-line fix is safe, or that the fix is unnecessary.  So
I just post it here, and let Gaby decide  ;-)

The issue was that a PHI got the wrong BLOCK_FOR_INSN assigned
to it in the case that it gets inserted into an otherwise empty
basic block.  The test case is derived from bitmap_find_bit:

struct list_def
{
  unsigned int indx;
  struct list_def *prev;
} list_def;

struct list_def *
foo (struct list_def *head, unsigned int bit, unsigned int indx)
{
  struct list_def *element;

  if (head->indx > indx)
    for (element = head;
         element->prev != 0 && element->indx > indx;
         element = element->prev)
      ;
  return element;
}

Gr.
Steven



	* ssa.c (insert_phi_node): Make sure that a PHI ends up
	in the correct basic block.

Index: ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ssa.c,v
retrieving revision 1.56
diff -c -3 -p -r1.56 ssa.c
*** ssa.c       27 Sep 2002 12:48:03 -0000      1.56
--- ssa.c       24 Aug 2004 19:39:54 -0000
*************** insert_phi_node (regno, bb)
*** 676,682 ****

    insn = first_insn_after_basic_block_note (b);
    end_p = PREV_INSN (insn) == b->end;
!   emit_insn_before (phi, insn);
    if (end_p)
      b->end = PREV_INSN (insn);
  }
--- 676,682 ----

    insn = first_insn_after_basic_block_note (b);
    end_p = PREV_INSN (insn) == b->end;
!   emit_insn_after (phi, PREV_INSN (insn));
    if (end_p)
      b->end = PREV_INSN (insn);
  }


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