diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-01 22:32:37 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-01 22:32:37 +0000 |
commit | 375b98af7a4ab51b0e6d87892321f2c30c1fcdeb (patch) | |
tree | 6afdbb92ab2cb0aed6d61ceda0f1ab8ccab13025 /gcc/gcse.c | |
parent | 8c2b9a3e52defdbdefab40ad9fa6a4675b6b4aa3 (diff) | |
download | gcc-375b98af7a4ab51b0e6d87892321f2c30c1fcdeb.tar.gz |
PR fortran/9974
* gcse.c (reg_killed_on_egde): New function to test whether the
given reg is overwritten by any instruction queued on an edge.
(bypass_block): Ignore substitutions killed on incoming edges.
Don't bypass outgoing edges that have queued instructions.
* gcc.c-torture/execute/20030401-1.c: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65148 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcse.c')
-rw-r--r-- | gcc/gcse.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/gcc/gcse.c b/gcc/gcse.c index 93f656f8804..e7a6845581d 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -624,6 +624,7 @@ static void find_implicit_sets PARAMS ((void)); static int one_cprop_pass PARAMS ((int, int, int)); static bool constprop_register PARAMS ((rtx, rtx, rtx, int)); static struct expr *find_bypass_set PARAMS ((int, int)); +static bool reg_killed_on_edge PARAMS ((rtx, edge)); static int bypass_block PARAMS ((basic_block, rtx, rtx)); static int bypass_conditional_jumps PARAMS ((void)); static void alloc_pre_mem PARAMS ((int, int)); @@ -4768,11 +4769,35 @@ find_bypass_set (regno, bb) } +/* Subroutine of bypass_block that checks whether a pseudo is killed by + any of the instructions inserted on an edge. Jump bypassing places + condition code setters on CFG edges using insert_insn_on_edge. This + function is required to check that our data flow analysis is still + valid prior to commit_edge_insertions. */ + +static bool +reg_killed_on_edge (reg, e) + rtx reg; + edge e; +{ + rtx insn; + + for (insn = e->insns; insn; insn = NEXT_INSN (insn)) + if (INSN_P (insn) && reg_set_p (reg, insn)) + return true; + + return false; +} + /* Subroutine of bypass_conditional_jumps that attempts to bypass the given basic block BB which has more than one predecessor. If not NULL, SETCC is the first instruction of BB, which is immediately followed by JUMP_INSN JUMP. Otherwise, SETCC is NULL, and JUMP is the first insn of BB. - Returns nonzero if a change was made. */ + Returns nonzero if a change was made. + + During the jump bypassing pass, we may place copies of SETCC instuctions + on CFG edges. The following routine must be careful to pay attention to + these inserted insns when performing its transformations. */ static int bypass_block (bb, setcc, jump) @@ -4780,7 +4805,7 @@ bypass_block (bb, setcc, jump) rtx setcc, jump; { rtx insn, note; - edge e, enext; + edge e, enext, edest; int i, change; int may_be_loop_header; @@ -4835,6 +4860,10 @@ bypass_block (bb, setcc, jump) if (! set) continue; + /* Check the data flow is valid after edge insertions. */ + if (e->insns && reg_killed_on_edge (reg_used->reg_rtx, e)) + continue; + src = SET_SRC (pc_set (jump)); if (setcc != NULL) @@ -4845,10 +4874,27 @@ bypass_block (bb, setcc, jump) new = simplify_replace_rtx (src, reg_used->reg_rtx, SET_SRC (set->expr)); + /* Jump bypassing may have already placed instructions on + edges of the CFG. We can't bypass an outgoing edge that + has instructions associated with it, as these insns won't + get executed if the incoming edge is redirected. */ + if (new == pc_rtx) - dest = FALLTHRU_EDGE (bb)->dest; + { + edest = FALLTHRU_EDGE (bb); + dest = edest->insns ? NULL : edest->dest; + } else if (GET_CODE (new) == LABEL_REF) - dest = BLOCK_FOR_INSN (XEXP (new, 0)); + { + dest = BLOCK_FOR_INSN (XEXP (new, 0)); + /* Don't bypass edges containing instructions. */ + for (edest = bb->succ; edest; edest = edest->succ_next) + if (edest->dest == dest && edest->insns) + { + dest = NULL; + break; + } + } else dest = NULL; |