From 1aa71af09350b9ff4d2fad88a440b682545682ec Mon Sep 17 00:00:00 2001 From: liuhongt Date: Tue, 11 Aug 2020 11:05:40 +0800 Subject: [PATCH] Refine expander vec_unpacku_float_hi_v16si/vec_unpacku_float_lo_v16si gcc/ PR target/96551 * config/i386/sse.md (vec_unpacku_float_hi_v16si): For vector compare to integer mask, don't use gen_rtx_LT, use ix86_expand_mask_vec_cmp instead. (vec_unpacku_float_hi_v16si): Ditto. gcc/testsuite * gcc.target/i386/avx512f-pr96551-1.c: New test. * gcc.target/i386/avx512f-pr96551-2.c: New test. --- gcc/config/i386/sse.md | 4 +-- .../gcc.target/i386/avx512f-pr96551-1.c | 18 ++++++++++ .../gcc.target/i386/avx512f-pr96551-2.c | 33 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-pr96551-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-pr96551-2.c diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 5e26e9c5aa2..8250325e1a3 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -7026,7 +7026,7 @@ emit_insn (gen_vec_extract_hi_v16si (tmp[3], operands[1])); emit_insn (gen_floatv8siv8df2 (tmp[2], tmp[3])); - emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0]))); + ix86_expand_mask_vec_cmp (k, LT, tmp[2], tmp[0]); emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k)); emit_move_insn (operands[0], tmp[2]); DONE; @@ -7073,7 +7073,7 @@ k = gen_reg_rtx (QImode); emit_insn (gen_avx512f_cvtdq2pd512_2 (tmp[2], operands[1])); - emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0]))); + ix86_expand_mask_vec_cmp (k, LT, tmp[2], tmp[0]); emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k)); emit_move_insn (operands[0], tmp[2]); DONE; diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr96551-1.c b/gcc/testsuite/gcc.target/i386/avx512f-pr96551-1.c new file mode 100644 index 00000000000..598bb6e85f3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr96551-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f -mprefer-vector-width=512" } */ + +unsigned int a[256]; +double b[256]; + +void +__attribute__ ((noipa, optimize ("tree-vectorize"))) +foo(void) +{ + int i; + + for (i=0; i<256; ++i) + b[i] = a[i]; +} + +/* { dg-final { scan-assembler "vcvtdq2pd\[^\n\]*zmm" } } */ + diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr96551-2.c b/gcc/testsuite/gcc.target/i386/avx512f-pr96551-2.c new file mode 100644 index 00000000000..f8bb1da7966 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr96551-2.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f -mprefer-vector-width=512" } */ +/* { dg-require-effective-target avx512f } */ + +#ifndef CHECK +#define CHECK "avx512f-helper.h" +#endif + +#include CHECK + +#ifndef TEST +#define TEST test_512 +#endif + +#include "avx512f-pr96551-1.c" + +void +test_512 (void) +{ + double exp[256]; + for (int i = 0; i != 256; i++) + { + a[i] = i * i + 3 * i + 13; + exp[i] = a[i]; + b[i] = 0; + } + + foo (); + + for (int i = 0; i != 256; i++) + if (exp[i] != b[i]) + abort (); +} -- 2.30.2