https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96243
Bug ID: 96243 Summary: For vector compare to mask register, UNSPEC is needed instead of comparison operator Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- Target: i386, x86-64 When tring to relax (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>" [(set (match_operand:<avx512fmaskmode> 0 "register_operand") - (unspec:<avx512fmaskmode> - [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand") - (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")] - UNSPEC_MASKED_EQ))] + (eq:<avx512fmaskmode> + (match_operand:VI48_AVX512VL 1 "nonimmediate_operand") + (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")))] "TARGET_AVX512F" "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);") I got runtime failure from gcc.target/i386/avx512vl-vpcmpeqq-2.c, that's because cse will take (eq:QI (V4DI: 90) (V4DI: 91)) as a boolean value and do some optimization, that's not correct for vector compare, also others places like combine hold the same assumption. The pattern like (define_insn "*<avx512>_cmp<mode>3<mask_scalar_merge_name><round_saeonly_name>" [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k") (match_operator:<avx512fmaskmode> 3 "ix86_comparison_int_operator" [(match_operand:VI48_AVX512VL 1 "register_operand" "v") (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "<round_saeonly_constraint>")]))] "TARGET_AVX512F && <round_saeonly_mode512bit_condition>" "vpcmp<ssemodesuffix>\t{%I3, <round_saeonly_mask_scalar_merge_op4>%2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2<round_saeonly_mask_scalar_merge_op4>, %I3}" [(set_attr "type" "ssecmp") (set_attr "length_immediate" "1") (set_attr "prefix" "evex") (set_attr "mode" "<sseinsnmode>")]) Need to be fixed.