Jeff Law <j...@ventanamicro.com> writes:
> This is another minor improvement to coremark.   I suspect this only 
> improves code size as the load-immediate was likely issuing with the ret 
> statement on multi-issue machines.
>
>
> Basically we're failing to utilize conditional equivalences during the 
> post-reload CSE pass.  So if a particular block is only reached when a 
> certain condition holds (say for example a4 == 0) and the block has an 
> assignment like a4 = 0, we would fail to eliminate the unnecessary 
> assignment.

I wasn't sure (and was too lazy to try, sorry), but: is the reason
that we fail to catch this earlier because the two uses of r4 are
entirely separate (i.e. not from the same pseudo)?

> +       /* Iterate over each incoming edge and see if they
> +          all have the same implicit set.  */
> +       FOR_EACH_EDGE (e, ei, bb->preds)
> +         {
> +           /* If the predecessor does not end in a conditional
> +              jump, then it does not have an implicit set.  */
> +           if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun)
> +               && !block_ends_with_condjump_p (e->src))
> +             {
> +               found = false;
> +               break;
> +             }
> +
> +           /* We know the predecessor ends with a conditional
> +              jump.  Now dig into the actal form of the jump
> +              to potentially extract an implicit set.  */

Very minor, but it looked odd to fall through for the entry block.
How about:

              if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun)
                  || !block_ends_with_condjump_p (e->src))

?

> +           rtx_insn *condjump = BB_END (e->src);
> +           if (condjump
> +               && any_condjump_p (condjump)
> +               && onlyjump_p (condjump))
> +             {
> +               /* Extract the condition.  */
> +               rtx pat = PATTERN (condjump);
> +               rtx i_t_e = SET_SRC (pat);
> +               gcc_assert (GET_CODE (i_t_e) == IF_THEN_ELSE);
> +               rtx cond = XEXP (i_t_e, 0);
> +               if ((GET_CODE (cond) == EQ
> +                    && GET_CODE (XEXP (i_t_e, 1)) == LABEL_REF
> +                    && XEXP (XEXP (i_t_e, 1), 0) == BB_HEAD (bb))
> +                   || (GET_CODE (cond) == NE
> +                       && XEXP (i_t_e, 2) == pc_rtx
> +                       && e->src->next_bb == bb))
> +                 {
> +                   /* If this is the first time through record
> +                      the source and destination.  */
> +                   if (!dest)
> +                     {
> +                       dest = XEXP (cond, 0);
> +                       src = XEXP (cond, 1);
> +                     }
> +                   /* If this is not the first time through, then
> +                      verify the source and destination match.  */
> +                   else if (dest == XEXP (cond, 0) && src == XEXP (cond, 1))
> +                     ;

FWIW, agree with what Richi said about using rtx_equal_p here.  We don't
necessarily end up with shared hard regs, especially if they originated
from different pseudos.

Thanks,
Richard

Reply via email to