This is the mail archive of the gcc@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]

Re: the failure in store motion


Jan Hubicka <jh@suse.cz> writes:

> Hi,
> looking at the failure, it seems to me that it is due to bug in 
> store_killed_in_insn_p.
> It is wrong, as mentioned by Graham for pure insns, but on the i386
> even for const calls, as the arguments are passed on the stack.
> 
> You must check the function ussage to kill the stores completely
> 
> Like this:
> 
> Index: gcse.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/gcse.c,v
> retrieving revision 1.144
> diff -c -3 -p -r1.144 gcse.c
> *** gcse.c	2001/08/04 06:07:59	1.144
> --- gcse.c	2001/08/06 10:58:07
> *************** store_killed_in_insn (x, insn)
> *** 6513,6519 ****
>     
>     if (GET_CODE (insn) == CALL_INSN)
>       {
> !       if (CONST_CALL_P (insn))
>   	return 0;
>         else
>   	return 1;
> --- 6512,6519 ----
>     
>     if (GET_CODE (insn) == CALL_INSN)
>       {
> !       if (CONST_CALL_P (insn)
> ! 	  && !find_loads (CALL_INSN_FUNCTION_USAGE (insn)))
>   	return 0;
>         else
>   	return 1;

Hmmm.
Let me give this a try.
As I said, it only fails miserably on x86, so it's likely something
very specific to that platform (like this type of thing).
Nope, doesn't help.
Even this, more conservative version doesn't work:

static int
store_killed_in_insn (x, insn)
     rtx x, insn;
{
  rtx set;
  if (!INSN_P (insn))
    return 0;
 
  if (GET_CODE (insn) == CALL_INSN)
    {
        return 1;
    }
  if (volatile_insn_p (PATTERN (insn)))
     return 1;
  if (multiple_sets (insn))
     return 1;
  set = single_set (insn);
  if (set)
    {
      /* Check for memory stores to aliased objects.  */
      if (GET_CODE (SET_DEST (set)) == MEM && !expr_equiv_p (SET_DEST (set), x))
        {
        if (find_loads (SET_DEST (set), x))
          return 1;
        }
      return find_loads (SET_SRC (set), x);
    }
  else
    return find_loads (PATTERN (insn), x);
}

(I also changed find_loads to look at set dests the same way
store_killed_in_insn does, so that it can handle parallels).

Even if you just tell it to remove available stores, we add testsuite
failures.

I wonder if it has to do with trapping or something? (We kill trapping
stores on abnormal edges before performing the reverse LCM, but we
don't kill them before we remove available loads)

However, even if you comment out removing the redundant avail stores,
always set not transparent and killed if it's killed in a basic block,
etc, you *still* get wrong answers.

So store_killed_in_insn isn't quite right, even in the above version.

--Dan

-- 
"When I was a baby, I kept a diary.  Recently, I was rereading
it.  It said, "Day 1 -- Still tired from the move.  Day 2 --
Everybody talks to me like I'm an idiot."
"-Steven Wright


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