[AArch64] Merge SVE FP unary patterns
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 7 Aug 2019 18:51:40 +0000 (18:51 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 7 Aug 2019 18:51:40 +0000 (18:51 +0000)
This patch merges the SVE FP rounding patterns with the other SVE
FP unary patterns.

At the moment, we only generate unary FP operations for full vectors,
so we can use (sqrt:VNx4SF ...) etc. in the rtl pattern.  With the ACLE,
it's also possible to generate predicated operations on partial vectors
without specifying a value for inactive lanes.  (sqrt:VNx4SF ...) would
then have different faulting behaviour from the instruction that the
pattern generates.

This patch therefore uses unspecs to represent the operations instead.
Later patches make this change for other patterns.

2019-08-07  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* config/aarch64/iterators.md (UNSPEC_COND_FABS, UNSPEC_COND_FNEG)
(UNSPEC_COND_FRINTA, UNSPEC_COND_FRINTI, UNSPEC_COND_FRINTM)
(UNSPEC_COND_FRINTN, UNSPEC_COND_FRINTP, UNSPEC_COND_FRINTX)
(UNSPEC_COND_FRINTZ, UNSPEC_COND_FSQRT): New unspecs.
(optab, sve_fp_op): Handle them.
(SVE_FP_UNARY): Delete.
(optab): Remove sqrt entry.
(sve_fp_op): Remove neg, abs and sqrt entries.
(SVE_COND_FP_UNARY): New int iterator.
* config/aarch64/aarch64-sve.md (<frint_pattern><mode>2)
(*<frint_pattern><mode>2): Delete.
(<SVE_FP_UNARY:optab><SVE_F:mode>2): Replace with...
(<SVE_COND_FP_UNARY:optab><SVE_F:mode>2): ...this.
(*<SVE_FP_UNARY:optab><SVE_F:mode>2): Replace with...
(*<SVE_COND_FP_UNARY:optab><SVE_F:mode>2): ...this.

From-SVN: r274187

gcc/ChangeLog
gcc/config/aarch64/aarch64-sve.md
gcc/config/aarch64/iterators.md

index c292eec60135ff45451dfd9e15cd7e7a74596309..3e31681f7378cfe38c2a3ef18fe8c807594952bb 100644 (file)
@@ -1,3 +1,21 @@
+2019-08-07  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * config/aarch64/iterators.md (UNSPEC_COND_FABS, UNSPEC_COND_FNEG)
+       (UNSPEC_COND_FRINTA, UNSPEC_COND_FRINTI, UNSPEC_COND_FRINTM)
+       (UNSPEC_COND_FRINTN, UNSPEC_COND_FRINTP, UNSPEC_COND_FRINTX)
+       (UNSPEC_COND_FRINTZ, UNSPEC_COND_FSQRT): New unspecs.
+       (optab, sve_fp_op): Handle them.
+       (SVE_FP_UNARY): Delete.
+       (optab): Remove sqrt entry.
+       (sve_fp_op): Remove neg, abs and sqrt entries.
+       (SVE_COND_FP_UNARY): New int iterator.
+       * config/aarch64/aarch64-sve.md (<frint_pattern><mode>2)
+       (*<frint_pattern><mode>2): Delete.
+       (<SVE_FP_UNARY:optab><SVE_F:mode>2): Replace with...
+       (<SVE_COND_FP_UNARY:optab><SVE_F:mode>2): ...this.
+       (*<SVE_FP_UNARY:optab><SVE_F:mode>2): Replace with...
+       (*<SVE_COND_FP_UNARY:optab><SVE_F:mode>2): ...this.
+
 2019-08-07  Richard Sandiford  <richard.sandiford@arm.com>
 
        * config/aarch64/aarch64-sve.md (*pred_fold_left_plus_<mode>): Delete.
index 6c40979cb6583c16e995d32fa007d02afbc906b1..1f5153a0e443d5a01745405c58a1897558038cfa 100644 (file)
@@ -50,8 +50,7 @@
 ;;
 ;; == Unary arithmetic
 ;; ---- [INT] General unary arithmetic corresponding to rtx codes
-;; ---- [FP] General unary arithmetic corresponding to rtx codes
-;; ---- [FP] Rounding
+;; ---- [FP] General unary arithmetic corresponding to unspecs
 ;; ---- [PRED] Inverse
 
 ;; == Binary arithmetic
 )
 
 ;; -------------------------------------------------------------------------
-;; ---- [FP] General unary arithmetic corresponding to rtx codes
+;; ---- [FP] General unary arithmetic corresponding to unspecs
 ;; -------------------------------------------------------------------------
 ;; Includes:
 ;; - FABS
 ;; - FNEG
-;; - FSQRT
-;; -------------------------------------------------------------------------
-
-;; Unpredicated floating-point unary operations.
-(define_expand "<optab><mode>2"
-  [(set (match_operand:SVE_F 0 "register_operand")
-       (unspec:SVE_F
-         [(match_dup 2)
-          (SVE_FP_UNARY:SVE_F (match_operand:SVE_F 1 "register_operand"))]
-         UNSPEC_MERGE_PTRUE))]
-  "TARGET_SVE"
-  {
-    operands[2] = aarch64_ptrue_reg (<VPRED>mode);
-  }
-)
-
-;; Predicated floating-point unary operations.
-(define_insn "*<optab><mode>2"
-  [(set (match_operand:SVE_F 0 "register_operand" "=w")
-       (unspec:SVE_F
-         [(match_operand:<VPRED> 1 "register_operand" "Upl")
-          (SVE_FP_UNARY:SVE_F (match_operand:SVE_F 2 "register_operand" "w"))]
-         UNSPEC_MERGE_PTRUE))]
-  "TARGET_SVE"
-  "<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>"
-)
-
-;; -------------------------------------------------------------------------
-;; ---- [FP] Rounding
-;; -------------------------------------------------------------------------
-;; Includes:
 ;; - FRINTA
 ;; - FRINTI
 ;; - FRINTM
 ;; - FRINTP
 ;; - FRINTX
 ;; - FRINTZ
+;; - FSQRT
 ;; -------------------------------------------------------------------------
 
-;; Unpredicated FRINTy.
-(define_expand "<frint_pattern><mode>2"
+;; Unpredicated floating-point unary operations.
+(define_expand "<optab><mode>2"
   [(set (match_operand:SVE_F 0 "register_operand")
        (unspec:SVE_F
          [(match_dup 2)
-          (unspec:SVE_F [(match_operand:SVE_F 1 "register_operand")]
-                        FRINT)]
-         UNSPEC_MERGE_PTRUE))]
+          (match_operand:SVE_F 1 "register_operand")]
+         SVE_COND_FP_UNARY))]
   "TARGET_SVE"
   {
     operands[2] = aarch64_ptrue_reg (<VPRED>mode);
   }
 )
 
-;; FRINTy predicated with a PTRUE.
-(define_insn "*<frint_pattern><mode>2"
+;; Predicated floating-point unary operations.
+(define_insn "*<optab><mode>2"
   [(set (match_operand:SVE_F 0 "register_operand" "=w")
        (unspec:SVE_F
          [(match_operand:<VPRED> 1 "register_operand" "Upl")
-          (unspec:SVE_F [(match_operand:SVE_F 2 "register_operand" "w")]
-                        FRINT)]
-         UNSPEC_MERGE_PTRUE))]
+          (match_operand:SVE_F 2 "register_operand" "w")]
+         SVE_COND_FP_UNARY))]
   "TARGET_SVE"
-  "frint<frint_suffix>\t%0.<Vetype>, %1/m, %2.<Vetype>"
+  "<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>"
 )
 
 ;; -------------------------------------------------------------------------
   [(set (match_operand:SVE_F 0 "register_operand" "=w")
        (unspec:SVE_F
          [(match_operand:<VPRED> 1 "register_operand" "Upl")
-          (abs:SVE_F
-            (minus:SVE_F
-              (match_operand:SVE_F 2 "register_operand" "0")
-              (match_operand:SVE_F 3 "register_operand" "w")))]
-       UNSPEC_MERGE_PTRUE))]
+          (minus:SVE_F
+            (match_operand:SVE_F 2 "register_operand" "0")
+            (match_operand:SVE_F 3 "register_operand" "w"))]
+       UNSPEC_COND_FABS))]
   "TARGET_SVE"
   "fabd\t%0.<Vetype>, %1/m, %2.<Vetype>, %3.<Vetype>"
 )
index fcd550ce7448279b3634d8b8cb2f1f70afcdd4de..1e39266cee82e77012fb791766faa0ab49219d3a 100644 (file)
     UNSPEC_XORF                ; Used in aarch64-sve.md.
     UNSPEC_SMUL_HIGHPART ; Used in aarch64-sve.md.
     UNSPEC_UMUL_HIGHPART ; Used in aarch64-sve.md.
+    UNSPEC_COND_FABS   ; Used in aarch64-sve.md.
     UNSPEC_COND_FADD   ; Used in aarch64-sve.md.
     UNSPEC_COND_FCMEQ  ; Used in aarch64-sve.md.
     UNSPEC_COND_FCMGE  ; Used in aarch64-sve.md.
     UNSPEC_COND_FMLA   ; Used in aarch64-sve.md.
     UNSPEC_COND_FMLS   ; Used in aarch64-sve.md.
     UNSPEC_COND_FMUL   ; Used in aarch64-sve.md.
+    UNSPEC_COND_FNEG   ; Used in aarch64-sve.md.
     UNSPEC_COND_FNMLA  ; Used in aarch64-sve.md.
     UNSPEC_COND_FNMLS  ; Used in aarch64-sve.md.
+    UNSPEC_COND_FRINTA ; Used in aarch64-sve.md.
+    UNSPEC_COND_FRINTI ; Used in aarch64-sve.md.
+    UNSPEC_COND_FRINTM ; Used in aarch64-sve.md.
+    UNSPEC_COND_FRINTN ; Used in aarch64-sve.md.
+    UNSPEC_COND_FRINTP ; Used in aarch64-sve.md.
+    UNSPEC_COND_FRINTX ; Used in aarch64-sve.md.
+    UNSPEC_COND_FRINTZ ; Used in aarch64-sve.md.
+    UNSPEC_COND_FSQRT  ; Used in aarch64-sve.md.
     UNSPEC_COND_FSUB   ; Used in aarch64-sve.md.
     UNSPEC_LASTB       ; Used in aarch64-sve.md.
     UNSPEC_FCADD90     ; Used in aarch64-simd.md.
 ;; SVE integer unary operations.
 (define_code_iterator SVE_INT_UNARY [abs neg not popcount])
 
-;; SVE floating-point unary operations.
-(define_code_iterator SVE_FP_UNARY [abs neg sqrt])
-
 ;; SVE integer binary operations.
 (define_code_iterator SVE_INT_BINARY [plus minus mult smax umax smin umin
                                      and ior xor])
                         (leu "leu")
                         (geu "geu")
                         (gtu "gtu")
-                        (abs "abs")
-                        (sqrt "sqrt")])
+                        (abs "abs")])
 
 ;; For comparison operators we use the FCM* and CM* instructions.
 ;; As there are no CMLE or CMLT instructions which act on 3 vector
 ;; The floating-point SVE instruction that implements an rtx code.
 (define_code_attr sve_fp_op [(plus "fadd")
                             (minus "fsub")
-                            (mult "fmul")
-                            (neg "fneg")
-                            (abs "fabs")
-                            (sqrt "fsqrt")])
+                            (mult "fmul")])
 
 ;; The SVE immediate constraint to use for an rtl code.
 (define_code_attr sve_imm_con [(eq "vsc")
 
 (define_int_iterator MUL_HIGHPART [UNSPEC_SMUL_HIGHPART UNSPEC_UMUL_HIGHPART])
 
+(define_int_iterator SVE_COND_FP_UNARY [UNSPEC_COND_FABS
+                                       UNSPEC_COND_FNEG
+                                       UNSPEC_COND_FRINTA
+                                       UNSPEC_COND_FRINTI
+                                       UNSPEC_COND_FRINTM
+                                       UNSPEC_COND_FRINTN
+                                       UNSPEC_COND_FRINTP
+                                       UNSPEC_COND_FRINTX
+                                       UNSPEC_COND_FRINTZ
+                                       UNSPEC_COND_FSQRT])
+
 (define_int_iterator SVE_COND_FP_BINARY [UNSPEC_COND_FADD
                                         UNSPEC_COND_FDIV
                                         UNSPEC_COND_FMAXNM
                        (UNSPEC_ANDV "and")
                        (UNSPEC_IORV "ior")
                        (UNSPEC_XORV "xor")
+                       (UNSPEC_COND_FABS "abs")
                        (UNSPEC_COND_FADD "add")
                        (UNSPEC_COND_FDIV "div")
                        (UNSPEC_COND_FMAXNM "smax")
                        (UNSPEC_COND_FMLA "fma")
                        (UNSPEC_COND_FMLS "fnma")
                        (UNSPEC_COND_FMUL "mul")
+                       (UNSPEC_COND_FNEG "neg")
                        (UNSPEC_COND_FNMLA "fnms")
                        (UNSPEC_COND_FNMLS "fms")
+                       (UNSPEC_COND_FRINTA "round")
+                       (UNSPEC_COND_FRINTI "nearbyint")
+                       (UNSPEC_COND_FRINTM "floor")
+                       (UNSPEC_COND_FRINTN "frintn")
+                       (UNSPEC_COND_FRINTP "ceil")
+                       (UNSPEC_COND_FRINTX "rint")
+                       (UNSPEC_COND_FRINTZ "btrunc")
+                       (UNSPEC_COND_FSQRT "sqrt")
                        (UNSPEC_COND_FSUB "sub")])
 
 (define_int_attr  maxmin_uns [(UNSPEC_UMAXV "umax")
                         (UNSPEC_COND_FCMLT "lt")
                         (UNSPEC_COND_FCMNE "ne")])
 
-(define_int_attr sve_fp_op [(UNSPEC_COND_FADD "fadd")
+(define_int_attr sve_fp_op [(UNSPEC_COND_FABS "fabs")
+                           (UNSPEC_COND_FADD "fadd")
                            (UNSPEC_COND_FDIV "fdiv")
                            (UNSPEC_COND_FMAXNM "fmaxnm")
                            (UNSPEC_COND_FMINNM "fminnm")
                            (UNSPEC_COND_FMUL "fmul")
+                           (UNSPEC_COND_FNEG "fneg")
+                           (UNSPEC_COND_FRINTA "frinta")
+                           (UNSPEC_COND_FRINTI "frinti")
+                           (UNSPEC_COND_FRINTM "frintm")
+                           (UNSPEC_COND_FRINTN "frintn")
+                           (UNSPEC_COND_FRINTP "frintp")
+                           (UNSPEC_COND_FRINTX "frintx")
+                           (UNSPEC_COND_FRINTZ "frintz")
+                           (UNSPEC_COND_FSQRT "fsqrt")
                            (UNSPEC_COND_FSUB "fsub")])
 
 (define_int_attr sve_fp_op_rev [(UNSPEC_COND_FADD "fadd")