diff mbox series

[committed,AArch64] Simplify WHILERW and WHILEWR definition

Message ID mptv9pk8xaz.fsf@arm.com
State New
Headers show
Series [committed,AArch64] Simplify WHILERW and WHILEWR definition | expand

Commit Message

Richard Sandiford Jan. 9, 2020, 3:27 p.m. UTC
I'd made WHILERW and WHILEWR use separate patterns from the SVE
WHILE instructions, but they're similar enough that we can use
a single pattern.  This means that we also get the flag-related
patterns "for free".

Tested on aarch64-linux-gnu and applied as r280054.

Richard


2020-01-09  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/aarch64/iterators.md (SVE_WHILE): Add UNSPEC_WHILERW
	and UNSPEC_WHILEWR.
	(while_optab_cmp): Handle them.
	* config/aarch64/aarch64-sve.md
	(*while_<while_optab_cmp><GPI:mode><PRED_ALL:mode>_ptest): Make public
	and add a "@" marker.
	* config/aarch64/aarch64-sve2.md (check_<raw_war>_ptrs<mode>): Use it
	instead of gen_aarch64_sve2_while_ptest.
	(@aarch64_sve2_while<cmp_op><GPI:mode><PRED_ALL:mode>_ptest): Delete.
diff mbox series

Patch

Index: gcc/config/aarch64/iterators.md
===================================================================
--- gcc/config/aarch64/iterators.md	2020-01-09 15:23:52.043234949 +0000
+++ gcc/config/aarch64/iterators.md	2020-01-09 15:26:21.862269517 +0000
@@ -2083,7 +2083,9 @@  (define_int_iterator SVE_CFP_TERNARY_LAN
 					   UNSPEC_FCMLA180 UNSPEC_FCMLA270])
 
 (define_int_iterator SVE_WHILE [UNSPEC_WHILELE UNSPEC_WHILELO
-				UNSPEC_WHILELS UNSPEC_WHILELT])
+				UNSPEC_WHILELS UNSPEC_WHILELT
+				(UNSPEC_WHILERW "TARGET_SVE2")
+				(UNSPEC_WHILEWR "TARGET_SVE2")])
 
 (define_int_iterator SVE2_WHILE_PTR [UNSPEC_WHILERW UNSPEC_WHILEWR])
 
@@ -2496,7 +2498,9 @@  (define_int_attr cmp_op [(UNSPEC_COND_CM
 (define_int_attr while_optab_cmp [(UNSPEC_WHILELE "le")
 				  (UNSPEC_WHILELO "ult")
 				  (UNSPEC_WHILELS "ule")
-				  (UNSPEC_WHILELT "lt")])
+				  (UNSPEC_WHILELT "lt")
+				  (UNSPEC_WHILERW "rw")
+				  (UNSPEC_WHILEWR "wr")])
 
 (define_int_attr raw_war [(UNSPEC_WHILERW "raw")
 			  (UNSPEC_WHILEWR "war")])
Index: gcc/config/aarch64/aarch64-sve.md
===================================================================
--- gcc/config/aarch64/aarch64-sve.md	2020-01-09 15:14:31.834844053 +0000
+++ gcc/config/aarch64/aarch64-sve.md	2020-01-09 15:26:21.862269517 +0000
@@ -6839,6 +6839,8 @@  (define_insn "*aarch64_pred_cmp<cmp_op><
 ;; - WHILELO
 ;; - WHILELS
 ;; - WHILELT
+;; - WHILERW (SVE2)
+;; - WHILEWR (SVE2)
 ;; -------------------------------------------------------------------------
 
 ;; Set element I of the result if (cmp (plus operand1 J) operand2) is
@@ -6883,7 +6885,7 @@  (define_insn_and_rewrite "*while_<while_
 )
 
 ;; Same, but handle the case in which only the flags result is useful.
-(define_insn_and_rewrite "*while_<while_optab_cmp><GPI:mode><PRED_ALL:mode>_ptest"
+(define_insn_and_rewrite "@while_<while_optab_cmp><GPI:mode><PRED_ALL:mode>_ptest"
   [(set (reg:CC_NZC CC_REGNUM)
 	(unspec:CC_NZC
 	  [(match_operand 3)
Index: gcc/config/aarch64/aarch64-sve2.md
===================================================================
--- gcc/config/aarch64/aarch64-sve2.md	2020-01-06 12:58:16.453794569 +0000
+++ gcc/config/aarch64/aarch64-sve2.md	2020-01-09 15:26:21.862269517 +0000
@@ -353,7 +353,7 @@  (define_expand "check_<raw_war>_ptrs<mod
 
   /* Emit a WHILERW or WHILEWR, setting the condition codes based on
      the result.  */
-  emit_insn (gen_aarch64_sve2_while_ptest
+  emit_insn (gen_while_ptest
 	     (<SVE2_WHILE_PTR:unspec>, <MODE>mode, pred_mode,
 	      gen_rtx_SCRATCH (pred_mode), operands[1], operands[2],
 	      CONSTM1_RTX (VNx16BImode), CONSTM1_RTX (pred_mode)));
@@ -365,27 +365,3 @@  (define_expand "check_<raw_war>_ptrs<mod
   emit_insn (gen_aarch64_cstore<mode> (operands[0], cmp, cc_reg));
   DONE;
 })
-
-;; A WHILERW or WHILEWR in which only the flags result is interesting.
-(define_insn_and_rewrite "@aarch64_sve2_while<cmp_op><GPI:mode><PRED_ALL:mode>_ptest"
-  [(set (reg:CC_NZC CC_REGNUM)
-	(unspec:CC_NZC
-	  [(match_operand 3)
-	   (match_operand 4)
-	   (const_int SVE_KNOWN_PTRUE)
-	   (unspec:PRED_ALL
-	     [(match_operand:GPI 1 "register_operand" "r")
-	      (match_operand:GPI 2 "register_operand" "r")]
-	     SVE2_WHILE_PTR)]
-	  UNSPEC_PTEST))
-   (clobber (match_scratch:PRED_ALL 0 "=Upa"))]
-  "TARGET_SVE2"
-  "while<cmp_op>\t%0.<PRED_ALL:Vetype>, %x1, %x2"
-  ;; Force the compiler to drop the unused predicate operand, so that we
-  ;; don't have an unnecessary PTRUE.
-  "&& (!CONSTANT_P (operands[3]) || !CONSTANT_P (operands[4]))"
-  {
-    operands[3] = CONSTM1_RTX (VNx16BImode);
-    operands[4] = CONSTM1_RTX (<PRED_ALL:MODE>mode);
-  }
-)