From: Hu, Lin1 Date: Fri, 7 Aug 2026 08:07:45 +0000 (+0800) Subject: i386: Don't use VCOMX for XFmode compares [PR126676] X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;p=thirdparty%2Fgcc.git i386: Don't use VCOMX for XFmode compares [PR126676] gcc/ChangeLog: PR target/126676 * config/i386/i386-expand.cc (ix86_expand_fp_compare): Only use UNSPEC_OPTCOMX for the modes VCOMX exists for. gcc/testsuite/ChangeLog: PR target/126676 * gcc.target/i386/pr126676.c: New test. --- diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index d0b92efc48b..fb4224af0da 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -2922,6 +2922,7 @@ ix86_expand_fp_compare (enum rtx_code code, rtx op0, rtx op1) rtx tmp, scratch; code = ix86_prepare_fp_compare_args (code, &op0, &op1); + machine_mode op_mode = GET_MODE (op0); tmp = gen_rtx_COMPARE (CCFPmode, op0, op1); if (unordered_compare) @@ -2932,14 +2933,14 @@ ix86_expand_fp_compare (enum rtx_code code, rtx op0, rtx op1) { case IX86_FPCMP_COMI: tmp = gen_rtx_COMPARE (CCFPmode, op0, op1); + /* VCOMX/VUCOMX only have DF/SF/HF mode instructions. */ + if (TARGET_AVX10_2 + && (code == EQ || code == NE) + && (op_mode == HFmode || op_mode == SFmode || op_mode == DFmode)) + tmp = gen_rtx_UNSPEC (CCFPmode, gen_rtvec (1, tmp), UNSPEC_OPTCOMX); /* We only have vcomisbf16, No vcomubf16 nor vcomxbf16 */ - if (GET_MODE (op0) != E_BFmode) - { - if (TARGET_AVX10_2 && (code == EQ || code == NE)) - tmp = gen_rtx_UNSPEC (CCFPmode, gen_rtvec (1, tmp), UNSPEC_OPTCOMX); - if (unordered_compare) - tmp = gen_rtx_UNSPEC (CCFPmode, gen_rtvec (1, tmp), UNSPEC_NOTRAP); - } + if (op_mode != BFmode && unordered_compare) + tmp = gen_rtx_UNSPEC (CCFPmode, gen_rtvec (1, tmp), UNSPEC_NOTRAP); cmp_mode = CCFPmode; emit_insn (gen_rtx_SET (gen_rtx_REG (CCFPmode, FLAGS_REG), tmp)); break; diff --git a/gcc/testsuite/gcc.target/i386/pr126676.c b/gcc/testsuite/gcc.target/i386/pr126676.c new file mode 100644 index 00000000000..219a6133790 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr126676.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -march=x86-64 -mavx10.2 -mapxf" } */ +/* { dg-final { scan-assembler-times "fucomip" 2 } } */ +/* { dg-final { scan-assembler-not "comx" } } */ + +int f1 (long double a, long double b, int x) { return x > 0 && a == b; } +int f2 (long double a, long double b, int x) { return x > 0 && a != b; }