diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 1996-08-29 21:17:59 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 1996-08-29 21:17:59 +0000 |
commit | 3d4579306a1e66fe78122b92c463f7f6bac4fce9 (patch) | |
tree | 1f22fc692f2f6860cec9d31caaf435fdd5a30d76 /gcc/config/pa | |
parent | 56a44361492dff17104a3d3ef2d5e87486363aae (diff) |
* pa/pa.md (fcmp patterns): Do not try to eliminate
useless add,tr insns here.
* pa/pa.c (pa_reorg): Do elimination of useless add,tr
insns here instead.
(print_operand, case 'y'): Remove this code.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@12677 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/pa')
-rw-r--r-- | gcc/config/pa/pa.c | 103 | ||||
-rw-r--r-- | gcc/config/pa/pa.md | 132 |
2 files changed, 84 insertions, 151 deletions
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 8adf58625f0..c2d7058e48c 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -3230,27 +3230,6 @@ print_operand (file, x, code) abort (); } return; - /* Reversed floating point comparison. Need special conditions to - deal with NaNs properly. */ - case 'y': - switch (GET_CODE (x)) - { - case EQ: - fputs ("=", file); break; - case NE: - fputs ("!=", file); break; - case GT: - fputs ("!<=", file); break; - case GE: - fputs ("!<", file); break; - case LT: - fputs ("!>=", file); break; - case LE: - fputs ("!>", file); break; - default: - abort (); - } - return; case 'S': /* Condition, operands are (S)wapped. */ switch (GET_CODE (x)) { @@ -5525,6 +5504,88 @@ pa_reorg (insns) /* This is fairly cheap, so always run it if optimizing. */ if (optimize > 0) { + /* Find all floating point compare + branch insns. If possible, + reverse the comparison & the branch to avoid add,tr insns. */ + insns = get_insns (); + for (insn = insns; insn; insn = NEXT_INSN (insn)) + { + rtx tmp, next_insn; + + /* Ignore anything that isn't an INSN. */ + if (GET_CODE (insn) != INSN) + continue; + + tmp = PATTERN (insn); + + /* It must be a set. */ + if (GET_CODE (tmp) != SET) + continue; + + /* The destination must be CCFP, which is register zero. */ + tmp = SET_DEST (tmp); + if (GET_CODE (tmp) != REG || REGNO (tmp) != 0) + continue; + + /* INSN should be a set of CCFP. + + See if the result of this insn is used in a reversed FP + conditional branch. If so, reverse our condition and + the branch. Doing so avoids useless add,tr insns. */ + next_insn = NEXT_INSN (insn); + while (next_insn) + { + /* Jumps, calls and labels stop our search. */ + if (GET_CODE (next_insn) == JUMP_INSN + || GET_CODE (next_insn) == CALL_INSN + || GET_CODE (next_insn) == CODE_LABEL) + break; + + /* As does another fcmp insn. */ + if (GET_CODE (next_insn) == INSN + && GET_CODE (PATTERN (next_insn)) == SET + && GET_CODE (SET_DEST (PATTERN (next_insn))) == REG + && REGNO (SET_DEST (PATTERN (next_insn))) == 0) + break; + + next_insn = NEXT_INSN (next_insn); + } + + /* Is NEXT_INSN a branch? */ + if (next_insn + && GET_CODE (next_insn) == JUMP_INSN) + { + rtx pattern = PATTERN (next_insn); + + /* If it a reversed fp conditional branch (eg uses add,tr) + and CCFP dies, then reverse our conditional and the branch + to avoid the add,tr. */ + if (GET_CODE (pattern) == SET + && SET_DEST (pattern) == pc_rtx + && GET_CODE (SET_SRC (pattern)) == IF_THEN_ELSE + && GET_CODE (XEXP (SET_SRC (pattern), 0)) == NE + && GET_CODE (XEXP (XEXP (SET_SRC (pattern), 0), 0)) == REG + && REGNO (XEXP (XEXP (SET_SRC (pattern), 0), 0)) == 0 + && GET_CODE (XEXP (SET_SRC (pattern), 1)) == PC + && find_regno_note (next_insn, REG_DEAD, 0)) + { + /* Reverse the branch. */ + tmp = XEXP (SET_SRC (pattern), 1); + XEXP (SET_SRC (pattern), 1) = XEXP (SET_SRC (pattern), 2); + XEXP (SET_SRC (pattern), 2) = tmp; + INSN_CODE (next_insn) = -1; + + /* Reverse our condition. */ + tmp = PATTERN (insn); + PUT_CODE (XEXP (tmp, 1), + reverse_condition (GET_CODE (XEXP (tmp, 1)))); + } + } + } + } + + /* This is fairly cheap, so always run it if optimizing. */ + if (optimize > 0) + { /* Find and explode all ADDR_VEC insns. */ insns = get_insns (); for (insn = insns; insn; insn = NEXT_INSN (insn)) diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md index 7a2dd8f1655..0084d95611e 100644 --- a/gcc/config/pa/pa.md +++ b/gcc/config/pa/pa.md @@ -385,71 +385,7 @@ [(match_operand:SF 0 "reg_or_0_operand" "fG") (match_operand:SF 1 "reg_or_0_operand" "fG")]))] "! TARGET_SOFT_FLOAT" - "* -{ - rtx next_insn; - - /* See if this is later used in a reversed FP branch. If so, reverse our - condition and the branch. Doing so avoids a useless add,tr. - - Don't do this if fcmp is in a delay slot since it's too much of a - headache to track down things on multiple paths. */ - if (dbr_sequence_length ()) - next_insn = NULL; - else - next_insn = NEXT_INSN (insn); - while (next_insn) - { - /* Jumps, calls and labels stop our search. */ - if (GET_CODE (next_insn) == JUMP_INSN - || GET_CODE (next_insn) == CALL_INSN - || GET_CODE (next_insn) == CODE_LABEL) - break; - - /* As does another fcmp insn. */ - if (GET_CODE (next_insn) == INSN - && GET_CODE (PATTERN (next_insn)) == SET - && GET_CODE (SET_DEST (PATTERN (next_insn))) == REG - && REGNO (SET_DEST (PATTERN (next_insn))) == 0) - break; - - if (GET_CODE (next_insn) == INSN - && GET_CODE (PATTERN (next_insn)) == SEQUENCE) - next_insn = XVECEXP (PATTERN (next_insn), 0, 0); - else - next_insn = NEXT_INSN (next_insn); - } - - /* Is NEXT_INSN a branch? */ - if (next_insn - && GET_CODE (next_insn) == JUMP_INSN) - { - rtx pattern = PATTERN (next_insn); - - /* Is it a reversed fp conditional branch (eg uses add,tr) and - CCFP dies, then reverse our conditional and the branch to - avoid the add,tr. */ - if (GET_CODE (pattern) == SET - && SET_DEST (pattern) == pc_rtx - && GET_CODE (SET_SRC (pattern)) == IF_THEN_ELSE - && GET_CODE (XEXP (SET_SRC (pattern), 0)) == NE - && GET_CODE (XEXP (XEXP (SET_SRC (pattern), 0), 0)) == REG - && REGNO (XEXP (XEXP (SET_SRC (pattern), 0), 0)) == 0 - && GET_CODE (XEXP (SET_SRC (pattern), 1)) == PC - && find_regno_note (next_insn, REG_DEAD, 0)) - - { - rtx tmp; - - tmp = XEXP (SET_SRC (pattern), 1); - XEXP (SET_SRC (pattern), 1) = XEXP (SET_SRC (pattern), 2); - XEXP (SET_SRC (pattern), 2) = tmp; - INSN_CODE (next_insn) = -1; - return \"fcmp,sgl,%y2 %r0,%r1\"; - } - } - return \"fcmp,sgl,%Y2 %r0,%r1\"; -}" + "fcmp,sgl,%Y2 %r0,%r1" [(set_attr "length" "4") (set_attr "type" "fpcc")]) @@ -459,71 +395,7 @@ [(match_operand:DF 0 "reg_or_0_operand" "fG") (match_operand:DF 1 "reg_or_0_operand" "fG")]))] "! TARGET_SOFT_FLOAT" - "* -{ - rtx next_insn; - - /* See if this is later used in a reversed FP branch. If so, reverse our - condition and the branch. Doing so avoids a useless add,tr. - - Don't do this if fcmp is in a delay slot since it's too much of a - headache to track down things on multiple paths. */ - if (dbr_sequence_length ()) - next_insn = NULL; - else - next_insn = NEXT_INSN (insn); - while (next_insn) - { - /* Jumps, calls and labels stop our search. */ - if (GET_CODE (next_insn) == JUMP_INSN - || GET_CODE (next_insn) == CALL_INSN - || GET_CODE (next_insn) == CODE_LABEL) - break; - - /* As does another fcmp insn. */ - if (GET_CODE (next_insn) == INSN - && GET_CODE (PATTERN (next_insn)) == SET - && GET_CODE (SET_DEST (PATTERN (next_insn))) == REG - && REGNO (SET_DEST (PATTERN (next_insn))) == 0) - break; - - if (GET_CODE (next_insn) == INSN - && GET_CODE (PATTERN (next_insn)) == SEQUENCE) - next_insn = XVECEXP (PATTERN (next_insn), 0, 0); - else - next_insn = NEXT_INSN (next_insn); - } - - /* Is NEXT_INSN a branch? */ - if (next_insn - && GET_CODE (next_insn) == JUMP_INSN) - { - rtx pattern = PATTERN (next_insn); - - /* Is it a reversed fp conditional branch (eg uses add,tr) and - CCFP dies, then reverse our conditional and the branch to - avoid the add,tr. */ - if (GET_CODE (pattern) == SET - && SET_DEST (pattern) == pc_rtx - && GET_CODE (SET_SRC (pattern)) == IF_THEN_ELSE - && GET_CODE (XEXP (SET_SRC (pattern), 0)) == NE - && GET_CODE (XEXP (XEXP (SET_SRC (pattern), 0), 0)) == REG - && REGNO (XEXP (XEXP (SET_SRC (pattern), 0), 0)) == 0 - && GET_CODE (XEXP (SET_SRC (pattern), 1)) == PC - && find_regno_note (next_insn, REG_DEAD, 0)) - - { - rtx tmp; - - tmp = XEXP (SET_SRC (pattern), 1); - XEXP (SET_SRC (pattern), 1) = XEXP (SET_SRC (pattern), 2); - XEXP (SET_SRC (pattern), 2) = tmp; - INSN_CODE (next_insn) = -1; - return \"fcmp,dbl,%y2 %r0,%r1\"; - } - } - return \"fcmp,dbl,%Y2 %r0,%r1\"; -}" + "fcmp,dbl,%Y2 %r0,%r1" [(set_attr "length" "4") (set_attr "type" "fpcc")]) |