RFA: patch cheking dangerous insns in sched-ebb.c

Vladimir Makarov vmakarov@redhat.com
Mon Feb 24 16:42:00 GMT 2003


Richard Henderson wrote:
> 
> On Sat, Feb 22, 2003 at 11:00:29AM -0500, Vladimir N. Makarov wrote:
> > The function may add at most one dependency for insn to a jump (because the
> > nested loop contains break when the dependency has been found).  The loop is
> > really not necessary for all insn except PFREE_CANDIDATE.
> 
> I see.
> 
> > Meanwhile, I improved the code (made loop explicitly only for
> > PFREE_CANDIDATEs) and attached it.
> 
> That is clearer, thanks.
> 
> > It can be improved more by creating and
> > modifying an additional structure (containing all preceding blocks and
> > adding a loop through the blocks in block_has_similiar_load.  The algorithm
> > will be still potentially n**2 but faster).
> 
> This seems easy enough to accomplish.  Untested, but...
> 
> > + static void
> > + add_deps_for_risky_insns (head, tail)
> > +      rtx head, tail;
> > + {
> > +   rtx insn, prev;
> > +   int class;
> > +   rtx last_jump = NULL_RTX;
> > +   rtx prev_head = PREV_INSN (head);
> > +   rtx next_tail = NEXT_INSN (tail);
>       basic_block last_block = NULL, bb;
> > +
> > +   for (insn = head; insn != next_tail; insn = NEXT_INSN (insn))
> > +     if (GET_CODE (insn) == JUMP_INSN)
>           {
>             bb = BLOCK_FOR_INSN (insn);
>             bb->aux = last_block;
>             last_block = bb;
> > +       last_jump = insn;
>           }
> > +     else if (INSN_P (insn) && last_jump != NULL_RTX)
> > +       {
> > +     class = haifa_classify_insn (insn);
>         switch (class)
>           {
>           case PFREE_CANDIDATE:
>             if (flag_schedule_speculative_load)
>               {
>                 for (bb = last_block; bb ; bb = bb->aux)
>                   if (!block_has_similiar_load (bb, insn))
>                     break;
>                 if (!bb)
>                   break;
>                 prev = bb->end;
>               }
>             /* FALLTHRU */
>           case TRAP_RISKY:
>           case IRISKY:
>           case PRISKY_CANDIDATE:
> > +         /* ??? We could implement better checking PRISKY_CANDIATEs
> > +            analogous to sched-rgn.c.  */
> > +         /* We can not change the mode of the backward
> > +            dependency because REG_DEP_ANTI has the lowest
> > +            rank.  */
> > +         if (add_dependence (insn, last_jump, REG_DEP_ANTI))
> > +           add_forward_dependence (last_jump, insn, REG_DEP_ANTI);
>             break;
> 
>           default:
>             break;
> > +       }
> > +       }
> 
>         /* Maintain the invariant that bb->aux is clear after use.  */
>         while (last_block)
>           {
>             bb = last_block->aux;
>             last_block->aux = NULL;
>             last_block = bb;
>           }
> > + }
> > +
> 
> Seem good?
> 

Yes, that is better.  I'll test it and send the final patch for
approval.

Vlad



More information about the Gcc-patches mailing list