]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Add another combine pattern for vfmin/max on cost model
authorPan Li <pan2.li@intel.com>
Tue, 17 Feb 2026 11:15:36 +0000 (19:15 +0800)
committerPan Li <pan2.li@intel.com>
Thu, 19 Feb 2026 01:12:24 +0000 (09:12 +0800)
The recent change introduce another form of vfmin/max, which is
more "literal" compare the previous one.  The related vx_vf/vf*
test cases also failed due to this change.  Thus, add the pattern
to make the test case happy.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.
* Fix the vx_vf/vf* testcases.

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*literal_v<ieee_fmaxmin_op>_vf_<mode>):
Add new pattern for vfmax/min combine to fx.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/config/riscv/autovec-opt.md

index 35476c8c4464e4bed905f29b1c64da86c36d2639..c86fb16586dc441afbe2b45c76ea77bac60130aa 100644 (file)
   [(set_attr "type" "vfminmax")]
 )
 
+(define_insn_and_split "*literal_v<ieee_fmaxmin_op>_vf_<mode>"
+  [(set (match_operand:V_VLSF    0 "register_operand")
+       (if_then_else:V_VLSF
+        (unspec:<VM>
+         [(match_operand:<VM>   1 "vector_mask_operand")
+          (match_operand        5 "vector_length_operand")
+          (match_operand        6 "const_int_operand")
+          (match_operand        7 "const_int_operand")
+          (match_operand        8 "const_int_operand")
+          (reg:SI VL_REGNUM)
+          (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
+        (unspec:V_VLSF
+         [(vec_duplicate:V_VLSF
+           (match_operand:<VEL> 3 "register_operand"))
+          (match_operand:V_VLSF 4 "register_operand")] UNSPEC_VFMAXMIN)
+        (unspec:V_VLSF
+         [(match_operand:DI     2 "register_operand")] UNSPEC_VUNDEF)))]
+  "TARGET_VECTOR && can_create_pseudo_p ()"
+  "#"
+  "&& 1"
+  [(const_int 0)]
+  {
+    rtx ops[] = {operands[0], operands[4], operands[3]};
+    insn_code icode = code_for_pred_scalar (<IEEE_FMAXMIN_OP>, <MODE>mode);
+    riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, ops);
+  }
+  [(set_attr "type" "vfminmax")])
+
 (define_insn_and_split "*v<ieee_fmaxmin_op>_vf_<mode>"
   [(set (match_operand:V_VLSF 0 "register_operand")
     (unspec:V_VLSF [