Introduce two new unspecs, UNSPEC_COND_SMAX and UNSPEC_COND_SMIN,
corresponding to rtl operators smax and smin. UNSPEC_COND_SMAX is used
to generate fmaxnm instruction and UNSPEC_COND_SMIN is used to generate
fminnm instruction.
With these new unspecs, we can generate SVE2 max/min instructions using
existing generic unpredicated and predicated instruction patterns that
use optab attribute. Thus, we have removed specialised instruction
patterns for max/min instructions that were using
SVE_COND_FP_MAXMIN_PUBLIC iterator.
No new test cases as the existing test cases should be enough to test
this refactoring.
gcc/ChangeLog:
* config/aarch64/aarch64-sve.md
(<fmaxmin><mode>3): Remove this instruction pattern.
(cond_<fmaxmin><mode>): Remove this instruction pattern.
* config/aarch64/iterators.md: New unspecs and changes to
iterators and attrs to use the new unspecs
---
gcc/config/aarch64/aarch64-sve.md | 33 -------------------
gcc/config/aarch64/iterators.md | 55 ++++++++++++++++++++-----------
2 files changed, 35 insertions(+), 53 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-sve.md
b/gcc/config/aarch64/aarch64-sve.md
index bfa28849adf..989ba9546d7 100644
--- a/gcc/config/aarch64/aarch64-sve.md
+++ b/gcc/config/aarch64/aarch64-sve.md
@@ -6600,39 +6600,6 @@
;; - FMINNM
;; -------------------------------------------------------------------------
-;; Unpredicated fmax/fmin (the libm functions). The optabs for the
-;; smax/smin rtx codes are handled in the generic section above.
-(define_expand "<fmaxmin><mode>3"
- [(set (match_operand:SVE_FULL_F 0 "register_operand")
- (unspec:SVE_FULL_F
- [(match_dup 3)
- (const_int SVE_RELAXED_GP)
- (match_operand:SVE_FULL_F 1 "register_operand")
- (match_operand:SVE_FULL_F 2 "aarch64_sve_float_maxmin_operand")]
- SVE_COND_FP_MAXMIN_PUBLIC))]
- "TARGET_SVE"
- {
- operands[3] = aarch64_ptrue_reg (<VPRED>mode);
- }
-)
-
-;; Predicated fmax/fmin (the libm functions). The optabs for the
-;; smax/smin rtx codes are handled in the generic section above.
-(define_expand "cond_<fmaxmin><mode>"
- [(set (match_operand:SVE_FULL_F 0 "register_operand")
- (unspec:SVE_FULL_F
- [(match_operand:<VPRED> 1 "register_operand")
- (unspec:SVE_FULL_F
- [(match_dup 1)
- (const_int SVE_RELAXED_GP)
- (match_operand:SVE_FULL_F 2 "register_operand")
- (match_operand:SVE_FULL_F 3 "aarch64_sve_float_maxmin_operand")]
- SVE_COND_FP_MAXMIN_PUBLIC)
- (match_operand:SVE_FULL_F 4 "aarch64_simd_reg_or_zero")]
- UNSPEC_SEL))]
- "TARGET_SVE"
-)
-
;; Predicated floating-point maximum/minimum.
(define_insn "@aarch64_pred_<optab><mode>"
[(set (match_operand:SVE_FULL_F 0 "register_operand")
diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index cf9ee2639a9..d3a457fc6d9 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -884,6 +884,8 @@
UNSPEC_COND_FSUB ; Used in aarch64-sve.md.
UNSPEC_COND_SCVTF ; Used in aarch64-sve.md.
UNSPEC_COND_UCVTF ; Used in aarch64-sve.md.
+ UNSPEC_COND_SMAX ; Used in aarch64-sve.md.
+ UNSPEC_COND_SMIN ; Used in aarch64-sve.md.
UNSPEC_LASTA ; Used in aarch64-sve.md.
UNSPEC_LASTB ; Used in aarch64-sve.md.
UNSPEC_ASHIFT_WIDE ; Used in aarch64-sve.md.
@@ -3094,7 +3096,9 @@
UNSPEC_COND_FMINNM
UNSPEC_COND_FMUL
UNSPEC_COND_FMULX
- UNSPEC_COND_FSUB])
+ UNSPEC_COND_FSUB
+ UNSPEC_COND_SMAX
+ UNSPEC_COND_SMIN])
;; Same as SVE_COND_FP_BINARY, but without codes that have a dedicated
;; <optab><mode>3 expander.
@@ -3105,7 +3109,9 @@
UNSPEC_COND_FMINNM
UNSPEC_COND_FMUL
UNSPEC_COND_FMULX
- UNSPEC_COND_FSUB])
+ UNSPEC_COND_FSUB
+ UNSPEC_COND_SMAX
+ UNSPEC_COND_SMIN])
(define_int_iterator SVE_COND_FP_BINARY_INT [UNSPEC_COND_FSCALE])
@@ -3117,13 +3123,17 @@
UNSPEC_COND_FMAXNM
UNSPEC_COND_FMIN
UNSPEC_COND_FMINNM
- UNSPEC_COND_FMUL])
+ UNSPEC_COND_FMUL
+ UNSPEC_COND_SMAX
+ UNSPEC_COND_SMIN])
(define_int_iterator SVE_COND_FP_BINARY_REG
[(UNSPEC_COND_FAMAX "TARGET_SVE_FAMINMAX")
(UNSPEC_COND_FAMIN "TARGET_SVE_FAMINMAX")
UNSPEC_COND_FDIV
- UNSPEC_COND_FMULX])
+ UNSPEC_COND_FMULX
+ UNSPEC_COND_SMAX
+ UNSPEC_COND_SMIN])
(define_int_iterator SVE_COND_FCADD [UNSPEC_COND_FCADD90
UNSPEC_COND_FCADD270])
@@ -3133,11 +3143,6 @@
UNSPEC_COND_FMIN
UNSPEC_COND_FMINNM])
-;; Floating-point max/min operations that correspond to optabs,
-;; as opposed to those that are internal to the port.
-(define_int_iterator SVE_COND_FP_MAXMIN_PUBLIC [UNSPEC_COND_FMAXNM
- UNSPEC_COND_FMINNM])
-
(define_int_iterator SVE_COND_FP_TERNARY [UNSPEC_COND_FMLA
UNSPEC_COND_FMLS
UNSPEC_COND_FNMLA
@@ -3715,9 +3720,9 @@
(UNSPEC_COND_FCVTZU "fixuns_trunc")
(UNSPEC_COND_FDIV "div")
(UNSPEC_COND_FMAX "fmax_nan")
- (UNSPEC_COND_FMAXNM "smax")
+ (UNSPEC_COND_FMAXNM "fmax")
(UNSPEC_COND_FMIN "fmin_nan")
- (UNSPEC_COND_FMINNM "smin")
+ (UNSPEC_COND_FMINNM "fmin")
(UNSPEC_COND_FMLA "fma")
(UNSPEC_COND_FMLS "fnma")
(UNSPEC_COND_FMUL "mul")
@@ -3737,16 +3742,16 @@
(UNSPEC_COND_FSQRT "sqrt")
(UNSPEC_COND_FSUB "sub")
(UNSPEC_COND_SCVTF "float")
- (UNSPEC_COND_UCVTF "floatuns")])
+ (UNSPEC_COND_UCVTF "floatuns")
+ (UNSPEC_COND_SMAX "smax")
+ (UNSPEC_COND_SMIN "smin")])