]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Enable V2BF/V4BF vec_cmp with AVX10.2 vcmppbf16
authorLevy Hsu <admin@levyhsu.com>
Wed, 4 Sep 2024 07:04:04 +0000 (16:34 +0930)
committerLevy Hsu <admin@levyhsu.com>
Thu, 12 Sep 2024 06:33:33 +0000 (06:33 +0000)
gcc/ChangeLog:

* config/i386/i386.cc (ix86_get_mask_mode):
Enable BFmode for targetm.vectorize.get_mask_mode with AVX10.2.
* config/i386/mmx.md (vec_cmp<mode>qi):
Implement vec_cmpv2bfqi and vec_cmpv4bfqi.

gcc/testsuite/ChangeLog:

* gcc.target/i386/part-vect-vec_cmpbf.c: New test.

gcc/config/i386/i386.cc
gcc/config/i386/mmx.md
gcc/testsuite/gcc.target/i386/part-vect-vec_cmpbf.c [new file with mode: 0644]

index 45320124b91c7b412cf3cb81ee222e9ef9489723..7dbae1d72e35649f719f450f62894abd53df6e3f 100644 (file)
@@ -24682,7 +24682,8 @@ ix86_get_mask_mode (machine_mode data_mode)
       /* AVX512FP16 only supports vector comparison
         to kmask for _Float16.  */
       || (TARGET_AVX512VL && TARGET_AVX512FP16
-         && GET_MODE_INNER (data_mode) == E_HFmode))
+         && GET_MODE_INNER (data_mode) == E_HFmode)
+      || (TARGET_AVX10_2_256 && GET_MODE_INNER (data_mode) == E_BFmode))
     {
       if (elem_size == 4
          || elem_size == 8
index 4bc191b874b386643ef31da323f9325c9664d55e..2f8d958dd5f04d2a207256d3d527623edf034497 100644 (file)
   DONE;
 })
 
+;;This instruction does not generate floating point exceptions
+(define_expand "vec_cmp<mode>qi"
+  [(set (match_operand:QI 0 "register_operand")
+       (match_operator:QI 1 ""
+         [(match_operand:VBF_32_64 2 "register_operand")
+          (match_operand:VBF_32_64 3 "nonimmediate_operand")]))]
+  "TARGET_AVX10_2_256"
+{
+  rtx op2 = lowpart_subreg (V8BFmode,
+                            force_reg (<MODE>mode, operands[2]), <MODE>mode);
+  rtx op3 = lowpart_subreg (V8BFmode,
+                            force_reg (<MODE>mode, operands[3]), <MODE>mode);
+
+  emit_insn (gen_vec_cmpv8bfqi (operands[0], operands[1], op2, op3));
+  DONE;
+})
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
 ;; Parallel half-precision floating point rounding operations.
diff --git a/gcc/testsuite/gcc.target/i386/part-vect-vec_cmpbf.c b/gcc/testsuite/gcc.target/i386/part-vect-vec_cmpbf.c
new file mode 100644 (file)
index 0000000..0bb720b
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -mavx10.2" } */
+/* { dg-final { scan-assembler-times "vcmppbf16" 10 } } */
+
+typedef __bf16 __attribute__((__vector_size__ (4))) v2bf;
+typedef __bf16 __attribute__((__vector_size__ (8))) v4bf;
+
+
+#define VCMPMN(type, op, name) \
+type  \
+__attribute__ ((noinline, noclone)) \
+vec_cmp_##type##type##name (type a, type b) \
+{ \
+  return a op b;  \
+}
+
+VCMPMN (v4bf, <, lt)
+VCMPMN (v2bf, <, lt)
+VCMPMN (v4bf, <=, le)
+VCMPMN (v2bf, <=, le)
+VCMPMN (v4bf, >, gt)
+VCMPMN (v2bf, >, gt)
+VCMPMN (v4bf, >=, ge)
+VCMPMN (v2bf, >=, ge)
+VCMPMN (v4bf, ==, eq)
+VCMPMN (v2bf, ==, eq)