i386: Add missing vector truncate patterns [PR92658].
Checks
Commit Message
Add missing insn patterns for v2si -> v2hi/v2qi and v2hi-> v2qi vector
truncate.
Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
Ok for trunk?
gcc/ChangeLog:
PR target/92658
* config/i386/mmx.md (truncv2hiv2qi2): New define_insn.
(truncv2si<mode>2): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr92658-avx512bw-trunc-2.c: New test.
---
gcc/config/i386/mmx.md | 21 +++++++++++++++
.../i386/pr92658-avx512bw-trunc-2.c | 27 +++++++++++++++++++
2 files changed, 48 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c
Comments
On Fri, Jun 2, 2023 at 2:49 AM liuhongt <hongtao.liu@intel.com> wrote:
>
> Add missing insn patterns for v2si -> v2hi/v2qi and v2hi-> v2qi vector
> truncate.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> Ok for trunk?
>
> gcc/ChangeLog:
>
> PR target/92658
> * config/i386/mmx.md (truncv2hiv2qi2): New define_insn.
> (truncv2si<mode>2): Ditto.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/i386/pr92658-avx512bw-trunc-2.c: New test.
OK.
Thanks,
Uros.
> ---
> gcc/config/i386/mmx.md | 21 +++++++++++++++
> .../i386/pr92658-avx512bw-trunc-2.c | 27 +++++++++++++++++++
> 2 files changed, 48 insertions(+)
> create mode 100644 gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c
>
> diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
> index dbcb850ffde..bb45098f797 100644
> --- a/gcc/config/i386/mmx.md
> +++ b/gcc/config/i386/mmx.md
> @@ -3667,6 +3667,27 @@ (define_expand "<insn>v2qiv2hi2"
> DONE;
> })
>
> +(define_insn "truncv2hiv2qi2"
> + [(set (match_operand:V2QI 0 "register_operand" "=v")
> + (truncate:V2QI
> + (match_operand:V2HI 1 "register_operand" "v")))]
> + "TARGET_AVX512VL && TARGET_AVX512BW"
> + "vpmovwb\t{%1, %0|%0, %1}"
> + [(set_attr "type" "ssemov")
> + (set_attr "prefix" "evex")
> + (set_attr "mode" "TI")])
> +
> +(define_mode_iterator V2QI_V2HI [V2QI V2HI])
> +(define_insn "truncv2si<mode>2"
> + [(set (match_operand:V2QI_V2HI 0 "register_operand" "=v")
> + (truncate:V2QI_V2HI
> + (match_operand:V2SI 1 "register_operand" "v")))]
> + "TARGET_AVX512VL && TARGET_MMX_WITH_SSE"
> + "vpmovd<mmxvecsize>\t{%1, %0|%0, %1}"
> + [(set_attr "type" "ssemov")
> + (set_attr "prefix" "evex")
> + (set_attr "mode" "TI")])
> +
> ;; Pack/unpack vector modes
> (define_mode_attr mmxpackmode
> [(V4HI "V8QI") (V2SI "V4HI")])
> diff --git a/gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c b/gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c
> new file mode 100644
> index 00000000000..2f5b7dc5668
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c
> @@ -0,0 +1,27 @@
> +/* PR target/92658 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -mavx512bw -mavx512vl" } */
> +/* { dg-final { scan-assembler-times "vpmovwb" 1 } } */
> +/* { dg-final { scan-assembler-times "vpmovdb" 1 { target { ! ia32 } } } } */
> +/* { dg-final { scan-assembler-times "vpmovdw" 1 { target { ! ia32 } } } } */
> +
> +void
> +foo (int* __restrict a, char* b)
> +{
> + b[0] = a[0];
> + b[1] = a[1];
> +}
> +
> +void
> +foo2 (short* __restrict a, char* b)
> +{
> + b[0] = a[0];
> + b[1] = a[1];
> +}
> +
> +void
> +foo3 (int* __restrict a, short* b)
> +{
> + b[0] = a[0];
> + b[1] = a[1];
> +}
> --
> 2.39.1.388.g2fc9e9ca3c
>
@@ -3667,6 +3667,27 @@ (define_expand "<insn>v2qiv2hi2"
DONE;
})
+(define_insn "truncv2hiv2qi2"
+ [(set (match_operand:V2QI 0 "register_operand" "=v")
+ (truncate:V2QI
+ (match_operand:V2HI 1 "register_operand" "v")))]
+ "TARGET_AVX512VL && TARGET_AVX512BW"
+ "vpmovwb\t{%1, %0|%0, %1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "prefix" "evex")
+ (set_attr "mode" "TI")])
+
+(define_mode_iterator V2QI_V2HI [V2QI V2HI])
+(define_insn "truncv2si<mode>2"
+ [(set (match_operand:V2QI_V2HI 0 "register_operand" "=v")
+ (truncate:V2QI_V2HI
+ (match_operand:V2SI 1 "register_operand" "v")))]
+ "TARGET_AVX512VL && TARGET_MMX_WITH_SSE"
+ "vpmovd<mmxvecsize>\t{%1, %0|%0, %1}"
+ [(set_attr "type" "ssemov")
+ (set_attr "prefix" "evex")
+ (set_attr "mode" "TI")])
+
;; Pack/unpack vector modes
(define_mode_attr mmxpackmode
[(V4HI "V8QI") (V2SI "V4HI")])
new file mode 100644
@@ -0,0 +1,27 @@
+/* PR target/92658 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512bw -mavx512vl" } */
+/* { dg-final { scan-assembler-times "vpmovwb" 1 } } */
+/* { dg-final { scan-assembler-times "vpmovdb" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "vpmovdw" 1 { target { ! ia32 } } } } */
+
+void
+foo (int* __restrict a, char* b)
+{
+ b[0] = a[0];
+ b[1] = a[1];
+}
+
+void
+foo2 (short* __restrict a, char* b)
+{
+ b[0] = a[0];
+ b[1] = a[1];
+}
+
+void
+foo3 (int* __restrict a, short* b)
+{
+ b[0] = a[0];
+ b[1] = a[1];
+}