From 7e204bd2f189850cb940677c99d8d93eb7dd40cd Mon Sep 17 00:00:00 2001 From: liuhongt Date: Mon, 24 Jan 2022 11:05:47 +0800 Subject: Add vect_recog_cond_expr_convert_pattern. The pattern converts (cond (cmp a b) (convert c) (convert d)) to (convert (cond (cmp a b) c d)) when 1) types_match (c, d) 2) single_use for (convert c) and (convert d) 3) TYPE_PRECISION (TREE_TYPE (c)) == TYPE_PRECISION (TREE_TYPE (a)) 4) INTEGERAL_TYPE_P (TREE_TYPE (c)) The pattern can save packing of mask and data(partial for data, 2 vs 1). gcc/ChangeLog: PR target/103771 * match.pd (cond_expr_convert_p): New match. * tree-vect-patterns.cc (gimple_cond_expr_convert_p): Declare. (vect_recog_cond_expr_convert_pattern): New. gcc/testsuite/ChangeLog: * gcc.target/i386/pr103771-2.c: New test. * gcc.target/i386/pr103771-3.c: New test. --- gcc/testsuite/gcc.target/i386/pr103771-2.c | 8 ++++++++ gcc/testsuite/gcc.target/i386/pr103771-3.c | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr103771-2.c create mode 100644 gcc/testsuite/gcc.target/i386/pr103771-3.c (limited to 'gcc/testsuite') diff --git a/gcc/testsuite/gcc.target/i386/pr103771-2.c b/gcc/testsuite/gcc.target/i386/pr103771-2.c new file mode 100644 index 0000000..962a3a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr103771-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=cascadelake -O3" } */ +/* { dg-final { scan-assembler-not "kunpck" } } */ +/* { dg-final { scan-assembler-not "kand" } } */ +/* { dg-final { scan-assembler-not "kor" } } */ +/* { dg-final { scan-assembler-not "kshift" } } */ + +#include "pr103771.c" diff --git a/gcc/testsuite/gcc.target/i386/pr103771-3.c b/gcc/testsuite/gcc.target/i386/pr103771-3.c new file mode 100644 index 0000000..ef379b2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr103771-3.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-march=cascadelake -O3" } */ +/* { dg-final { scan-assembler-not "kunpck" } } */ +/* { dg-final { scan-assembler-not "kand" } } */ +/* { dg-final { scan-assembler-not "kor" } } */ +/* { dg-final { scan-assembler-not "kshift" } } */ + +typedef unsigned char uint8_t; + +static uint8_t x264_clip_uint8 (int x, unsigned int y) +{ + return x & (~255) ? (-x) >> 31 : y; +} + +void +mc_weight (uint8_t* __restrict dst, uint8_t* __restrict src, + int i_width,int i_scale, unsigned int* __restrict y) +{ + for(int x = 0; x < i_width; x++) + dst[x] = x264_clip_uint8 (src[x] * i_scale, y[x]); +} -- cgit v1.1