i386: Support vec_cmp for V8BF/V16BF/V32BF in AVX10.2

gcc/ChangeLog:

	* config/i386/i386-expand.cc (ix86_use_mask_cmp_p): Add BFmode
	for int mask cmp.
	* config/i386/sse.md (vec_cmp<mode><avx512fmaskmodelower>): New
	vec_cmp expand for VBF modes.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx10_2-512-bf-vector-cmpp-1.c: New test.
	* gcc.target/i386/avx10_2-bf-vector-cmpp-1.c: Ditto.
This commit is contained in:
Levy Hsu 2024-09-02 10:24:49 +08:00 committed by Haochen Jiang
parent e19f65b0be
commit f77435aa39
4 changed files with 63 additions and 0 deletions

View file

@ -4036,6 +4036,8 @@ ix86_use_mask_cmp_p (machine_mode mode, machine_mode cmp_mode,
return true;
else if (GET_MODE_INNER (cmp_mode) == HFmode)
return true;
else if (GET_MODE_INNER (cmp_mode) == BFmode)
return true;
/* When op_true is NULL, op_false must be NULL, or vice versa. */
gcc_assert (!op_true == !op_false);

View file

@ -4797,6 +4797,19 @@
DONE;
})
(define_expand "vec_cmp<mode><avx512fmaskmodelower>"
[(set (match_operand:<avx512fmaskmode> 0 "register_operand")
(match_operator:<avx512fmaskmode> 1 ""
[(match_operand:VBF_AVX10_2 2 "register_operand")
(match_operand:VBF_AVX10_2 3 "nonimmediate_operand")]))]
"TARGET_AVX10_2_256"
{
bool ok = ix86_expand_mask_vec_cmp (operands[0], GET_CODE (operands[1]),
operands[2], operands[3]);
gcc_assert (ok);
DONE;
})
(define_expand "vec_cmp<mode><sseintvecmodelower>"
[(set (match_operand:<sseintvecmode> 0 "register_operand")
(match_operator:<sseintvecmode> 1 ""

View file

@ -0,0 +1,19 @@
/* { dg-do compile } */
/* { dg-options "-mavx10.2-512 -O2 -mprefer-vector-width=512" } */
/* { dg-final { scan-assembler-times "vcmppbf16" 5 } } */
typedef __bf16 v32bf __attribute__ ((__vector_size__ (64)));
#define VCMPMN(type, op, name) \
type \
__attribute__ ((noinline, noclone)) \
vec_cmp_##type##type##name (type a, type b) \
{ \
return a op b; \
}
VCMPMN (v32bf, <, lt)
VCMPMN (v32bf, <=, le)
VCMPMN (v32bf, >, gt)
VCMPMN (v32bf, >=, ge)
VCMPMN (v32bf, ==, eq)

View file

@ -0,0 +1,29 @@
/* { dg-do compile } */
/* { dg-options "-mavx10.2 -O2" } */
/* { dg-final { scan-assembler-times "vcmppbf16" 10 } } */
typedef __bf16 v16bf __attribute__ ((__vector_size__ (32)));
typedef __bf16 v8bf __attribute__ ((__vector_size__ (16)));
#define VCMPMN(type, op, name) \
type \
__attribute__ ((noinline, noclone)) \
vec_cmp_##type##type##name (type a, type b) \
{ \
return a op b; \
}
VCMPMN (v16bf, <, lt)
VCMPMN (v8bf, <, lt)
VCMPMN (v16bf, <=, le)
VCMPMN (v8bf, <=, le)
VCMPMN (v16bf, >, gt)
VCMPMN (v8bf, >, gt)
VCMPMN (v16bf, >=, ge)
VCMPMN (v8bf, >=, ge)
VCMPMN (v16bf, ==, eq)
VCMPMN (v8bf, ==, eq)