diff mbox series

[1/2] rs6000: Update conditional jump patterns, no more (pc) (label_ref)

Message ID 3fa5f0578433a3995264bcf466c8b92ea4769070.1507497573.git.segher@kernel.crashing.org
State New
Headers show
Series [1/2] rs6000: Update conditional jump patterns, no more (pc) (label_ref) | expand

Commit Message

Segher Boessenkool Oct. 8, 2017, 10:29 p.m. UTC
Currently we have two patterns for every conditional jump: one jumping
if some condition is met, and the other jumping if it is not met.  We
don't need that second form because all our conditions have an opposite
already, and the generic code can deal with that just fine.

This patch deletes that second form.  We generated it directly in one
case; adjusted here.  Bootstrapped and regression checked on
powerpc64-linux {-m32,-m64}; also compared the generated binaries for
cc1 and vmlinux, no changes (other than the obvious ones for cc1).

Committing to trunk.


Segher


2017-10-08  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/rs6000/rs6000-string.c (expand_strncmp_align_check): Invert
	a conditional jump (and the compare for it) so that pc_rtx is the
	last operand.
	* config/rs6000/rs6000.c (rs6000_legitimate_combined_insn): Adjust
	for the deleted and renamed ctr<mode>_internal[234] patterns.
	* config/rs6000/rs6000.md: Delete second conditional branch pattern.
	Delete second conditional return pattern.
	(ctr<mode>_internal2): Delete this second bdnz pattern.
	(ctr<mode>_internal3): Rename to ctr<mode>_internal2.
	(ctr<mode>_internal4): Delete this second bdz pattern.

---
 gcc/config/rs6000/rs6000-string.c |  4 +-
 gcc/config/rs6000/rs6000.c        |  6 +--
 gcc/config/rs6000/rs6000.md       | 81 +--------------------------------------
 3 files changed, 4 insertions(+), 87 deletions(-)
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000-string.c b/gcc/config/rs6000/rs6000-string.c
index 19463c9..8c2a93e 100644
--- a/gcc/config/rs6000/rs6000-string.c
+++ b/gcc/config/rs6000/rs6000-string.c
@@ -674,10 +674,10 @@  expand_strncmp_align_check (rtx strncmp_label, rtx src, HOST_WIDE_INT bytes)
   emit_move_insn (cond, gen_rtx_COMPARE (CCmode, src_check,
 					 GEN_INT (4096 - bytes)));
 
-  rtx cmp_rtx = gen_rtx_LT (VOIDmode, cond, const0_rtx);
+  rtx cmp_rtx = gen_rtx_GE (VOIDmode, cond, const0_rtx);
 
   rtx ifelse = gen_rtx_IF_THEN_ELSE (VOIDmode, cmp_rtx,
-				     pc_rtx, lab_ref);
+				     lab_ref, pc_rtx);
   rtx j = emit_jump_insn (gen_rtx_SET (pc_rtx, ifelse));
   JUMP_LABEL (j) = strncmp_label;
   LABEL_NUSES (strncmp_label) += 1;
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b903f47..104f2ed 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -9051,11 +9051,7 @@  rs6000_legitimate_combined_insn (rtx_insn *insn)
       && (icode == CODE_FOR_ctrsi_internal1
 	  || icode == CODE_FOR_ctrdi_internal1
 	  || icode == CODE_FOR_ctrsi_internal2
-	  || icode == CODE_FOR_ctrdi_internal2
-	  || icode == CODE_FOR_ctrsi_internal3
-	  || icode == CODE_FOR_ctrdi_internal3
-	  || icode == CODE_FOR_ctrsi_internal4
-	  || icode == CODE_FOR_ctrdi_internal4))
+	  || icode == CODE_FOR_ctrdi_internal2))
     return false;
 
   return true;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index d8767de..e3132c2 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -12626,37 +12626,6 @@  (define_insn ""
   [(set_attr "type" "jmpreg")
    (set_attr "length" "4")])
 
-(define_insn ""
-  [(set (pc)
-	(if_then_else (match_operator 1 "branch_comparison_operator"
-				      [(match_operand 2
-						      "cc_reg_operand" "y")
-				       (const_int 0)])
-		      (pc)
-		      (label_ref (match_operand 0 "" ""))))]
-  ""
-  "*
-{
-  return output_cbranch (operands[1], \"%l0\", 1, insn);
-}"
-  [(set_attr "type" "branch")])
-
-(define_insn ""
-  [(set (pc)
-	(if_then_else (match_operator 0 "branch_comparison_operator"
-				      [(match_operand 1
-						      "cc_reg_operand" "y")
-				       (const_int 0)])
-		      (pc)
-		      (any_return)))]
-  "<return_pred>"
-  "*
-{
-  return output_cbranch (operands[0], NULL, 1, insn);
-}"
-  [(set_attr "type" "jmpreg")
-   (set_attr "length" "4")])
-
 ;; Logic on condition register values.
 
 ; This pattern matches things like
@@ -12933,33 +12902,9 @@  (define_insn "ctr<mode>_internal1"
   [(set_attr "type" "branch")
    (set_attr "length" "*,16,20,20")])
 
-(define_insn "ctr<mode>_internal2"
-  [(set (pc)
-	(if_then_else (ne (match_operand:P 1 "register_operand" "c,*b,*b,*b")
-			  (const_int 1))
-		      (pc)
-		      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*d*wi*c*l")
-	(plus:P (match_dup 1)
-		 (const_int -1)))
-   (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
-   (clobber (match_scratch:P 4 "=X,X,&r,r"))]
-  ""
-  "*
-{
-  if (which_alternative != 0)
-    return \"#\";
-  else if (get_attr_length (insn) == 4)
-    return \"bdz %l0\";
-  else
-    return \"bdnz $+8\;b %l0\";
-}"
-  [(set_attr "type" "branch")
-   (set_attr "length" "*,16,20,20")])
-
 ;; Similar but use EQ
 
-(define_insn "ctr<mode>_internal3"
+(define_insn "ctr<mode>_internal2"
   [(set (pc)
 	(if_then_else (eq (match_operand:P 1 "register_operand" "c,*b,*b,*b")
 			  (const_int 1))
@@ -12983,30 +12928,6 @@  (define_insn "ctr<mode>_internal3"
   [(set_attr "type" "branch")
    (set_attr "length" "*,16,20,20")])
 
-(define_insn "ctr<mode>_internal4"
-  [(set (pc)
-	(if_then_else (eq (match_operand:P 1 "register_operand" "c,*b,*b,*b")
-			  (const_int 1))
-		      (pc)
-		      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*d*wi*c*l")
-	(plus:P (match_dup 1)
-		 (const_int -1)))
-   (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
-   (clobber (match_scratch:P 4 "=X,X,&r,r"))]
-  ""
-  "*
-{
-  if (which_alternative != 0)
-    return \"#\";
-  else if (get_attr_length (insn) == 4)
-    return \"bdnz %l0\";
-  else
-    return \"bdz $+8\;b %l0\";
-}"
-  [(set_attr "type" "branch")
-   (set_attr "length" "*,16,20,20")])
-
 ;; Now the splitters if we could not allocate the CTR register
 
 (define_split