------- Additional Comments From amylaar at gcc dot gnu dot org  2004-10-15 15:49 
-------
Looking closer, I see that sched-deps.c already has code to keep branches, calls
and USEs at the end of the last basic block.
The problem is that lcm.c:optimize_mode_switching has put some
instructions after the USE before sched1 is run.

In this code:
    /* Split the edge from the entry block and the fallthrough edge to the
       exit block, so that we can note that there NORMAL_MODE is supplied /
       required.  */
    edge eg;
    edge_iterator ei;
    post_entry = split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
    /* The only non-call predecessor at this stage is a block with a
       fallthrough edge; there can be at most one, but there could be
       none at all, e.g. when exit is called.  */
    pre_exit = 0;
    FOR_EACH_EDGE (eg, ei, EXIT_BLOCK_PTR->preds)
      if (eg->flags & EDGE_FALLTHRU)
        {
          regset live_at_end = eg->src->global_live_at_end;

          gcc_assert (!pre_exit);
          pre_exit = split_edge (eg);
          COPY_REG_SET (pre_exit->global_live_at_start, live_at_end);
          COPY_REG_SET (pre_exit->global_live_at_end, live_at_end);
          break;
        }
  }

We create a new block at the end to put the final mode switch into.
If the fall-through predecessor of the exit block is the only predecessor
of the exit block, and it ends with a USE, then instead of split_edge
we should use split_block, to place the USE and the preceding copy from
the result to the return value register into the new block.

I would write a patch for this, but the copyright assignment for STM is not
finished yet.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16482

Reply via email to