public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Partially revert recent H8 patch for conditional branches
@ 2020-11-22 17:56 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2020-11-22 17:56 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 843 bytes --]

    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.
   

Installing on the trunk momentarily.

jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 3657 bytes --]

commit 86148e6754fd5745190b381bd3e45eee11faaef9
Author: Jeff Law <law@redhat.com>
Date:   Sun Nov 22 10:53:14 2020 -0700

    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/jumpcallmd (branch_true, branch_false): Revert
            recent change.  Ensure operand[0] is always the target label.

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-22 17:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 17:56 [committed] Partially revert recent H8 patch for conditional branches Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).