From fdd2fb172940c5fc60e1d8195b30f7ebc0e754d0 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sun, 22 Nov 2020 10:53:14 -0700 Subject: [PATCH] Partially revert recent H8 patch for conditional branches So I'd forgotten an important tidbit on the H8 port. Specifically for a branch instruction, the target label must be operand 0 for the length computations. This really only affects the main conditional branch pattern. The other conditional branch patterns are split and ultimately funnel into the main pattern. This patch fixes the issue by partially reverting an earlier change. This issue didn't show up until late in the optimization work on cc0 removal of the H8 port, but was caught by the testsuite. So there's no new test. Built and regression tested H8 with this change, with and without the cc0 removal patches. gcc/ * config/h8300/jumpcall.md (branch_true, branch_false): Revert recent change. Ensure operand[0] is always the target label. --- gcc/config/h8300/jumpcall.md | 66 ++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/gcc/config/h8300/jumpcall.md b/gcc/config/h8300/jumpcall.md index 3917cf18920..650b5e6fb70 100644 --- a/gcc/config/h8300/jumpcall.md +++ b/gcc/config/h8300/jumpcall.md @@ -37,44 +37,60 @@ DONE; }) -(define_insn "branch" +(define_insn "branch_true" [(set (pc) - (if_then_else (match_operator 2 "comparison_operator" + (if_then_else (match_operator 1 "comparison_operator" [(cc0) (const_int 0)]) - (match_operand 0 "pc_or_label_operand" "") - (match_operand 1 "pc_or_label_operand" "")))] - "operands[0] == pc_rtx || operands[1] == pc_rtx" + (label_ref (match_operand 0 "" "")) + (pc)))] + "" { if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 - && (GET_CODE (operands[2]) == GT - || GET_CODE (operands[2]) == GE - || GET_CODE (operands[2]) == LE - || GET_CODE (operands[2]) == LT)) + && (GET_CODE (operands[1]) == GT + || GET_CODE (operands[1]) == GE + || GET_CODE (operands[1]) == LE + || GET_CODE (operands[1]) == LT)) { cc_status.flags &= ~CC_OVERFLOW_UNUSABLE; return 0; } - if (operands[0] != pc_rtx) - { - if (get_attr_length (insn) == 2) - return "b%j2 %l0"; - else if (get_attr_length (insn) == 4) - return "b%j2 %l0:16"; - else - return "b%k2 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:"; - } + if (get_attr_length (insn) == 2) + return "b%j1 %l0"; + else if (get_attr_length (insn) == 4) + return "b%j1 %l0:16"; else + return "b%k1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:"; +} + [(set_attr "type" "branch") + (set_attr "cc" "none")]) + +(define_insn "branch_false" + [(set (pc) + (if_then_else (match_operator 1 "comparison_operator" + [(cc0) (const_int 0)]) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" +{ + if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 + && (GET_CODE (operands[1]) == GT + || GET_CODE (operands[1]) == GE + || GET_CODE (operands[1]) == LE + || GET_CODE (operands[1]) == LT)) { - if (get_attr_length (insn) == 2) - return "b%k2 %l1"; - else if (get_attr_length (insn) == 4) - return "b%k2 %l1:16"; - else - return "b%j2 .Lh8BR%=\;jmp @%l1\\n.Lh8BR%=:"; + cc_status.flags &= ~CC_OVERFLOW_UNUSABLE; + return 0; } + + if (get_attr_length (insn) == 2) + return "b%k1 %l0"; + else if (get_attr_length (insn) == 4) + return "b%k1 %l0:16"; + else + return "b%j1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:"; } - [(set_attr "type" "branch") + [(set_attr "type" "branch") (set_attr "cc" "none")]) ;; The brabc/brabs patterns have been disabled because their length computation -- 2.30.2