From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 609D03858D20 for ; Thu, 17 Feb 2022 09:48:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 609D03858D20 Received: by mail-ej1-x62d.google.com with SMTP id vz16so5958035ejb.0 for ; Thu, 17 Feb 2022 01:48:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cey5qlnxcmou3wbqYsOD23vQu9lQBJ/c6H0ryjPjl2w=; b=WuU5OipYxDJFlk73gNblQ6HfLuxixlPgwbL30/ytmpg8QesK+lxYysfMMFj6TaNF8v 9daNJrhAwPRuMslHTT11o90w0IW8l+7gYsqLKN5MM/I4ohZdPXO0+8pL0lkIGYZGz1zm 6WY0iYOR6LFFTYyNCNl0xop2Q3ES17Td9DzBn+LGkJHk1+vCRGx3AkdWjDSEMkt0KNkK mJjfUf2WhscGvRSuiyWLlvelyPwl5/mK2XOEWQ1ez/5Fg06b4VyBxj7j9/8tncIDne+S B4Io1lcj7+xlxomCnyHLFpab+M3gKem3yBVxfwUuSv3M1gIoEbL+XYiHllm8OnWT/+Tl 2Qdg== X-Gm-Message-State: AOAM531HxII/PjeYrJNIY/nqQpv9ZAv6u7wPnccoWI4FK/pWWAQvSniO SnZQfCPCIpXH86WhqyFXb2gVvIZrsW15P1nG1UY= X-Google-Smtp-Source: ABdhPJwKHw7eciTu6vIAU7Aco2Hgaqd5+6L8E+4r7LhHOz6Waxkofi17EEG9MHFgbEipwWSLCh5zi5Xllgp6k1dbtCM= X-Received: by 2002:a17:907:788c:b0:6ce:29d5:c075 with SMTP id ku12-20020a170907788c00b006ce29d5c075mr1723615ejc.407.1645091298179; Thu, 17 Feb 2022 01:48:18 -0800 (PST) MIME-Version: 1.0 References: <20220217053126.49814-1-hongtao.liu@intel.com> In-Reply-To: <20220217053126.49814-1-hongtao.liu@intel.com> From: Richard Biener Date: Thu, 17 Feb 2022 10:48:06 +0100 Message-ID: Subject: Re: [PATCH V2] Restrict the two sources of vect_recog_cond_expr_convert_pattern to be of the same type when convert is extension. To: liuhongt Cc: GCC Patches , Jakub Jelinek Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Feb 2022 09:48:29 -0000 On Thu, Feb 17, 2022 at 6:32 AM liuhongt via Gcc-patches wrote: > > > I find this quite unreadable, it looks like if @2 and @3 are treated > > differently. I think keeping the old 3 lines and just adding > > && (TYPE_PRECISION (TREE_TYPE (@0)) >= TYPE_PRECISION (type) > > || (TYPE_UNSIGNED (TREE_TYPE (@2)) > > == TYPE_UNSIGNED (TREE_TYPE (@3)))) > > after it ideally with a comment why would be better. > Update patch. OK. Thanks, Richard. > gcc/ChangeLog: > > PR tree-optimization/104551 > PR tree-optimization/103771 > * match.pd (cond_expr_convert_p): Add types_match check when > convert is extension. > * tree-vect-patterns.cc > (gimple_cond_expr_convert_p): Adjust comments. > (vect_recog_cond_expr_convert_pattern): Ditto. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/pr104551.c: New test. > --- > gcc/match.pd | 6 ++++++ > gcc/testsuite/gcc.target/i386/pr104551.c | 24 ++++++++++++++++++++++++ > gcc/tree-vect-patterns.cc | 6 ++++-- > 3 files changed, 34 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/i386/pr104551.c > > diff --git a/gcc/match.pd b/gcc/match.pd > index 05a10ab6bfd..8b6f22f1065 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -7698,5 +7698,11 @@ and, > == TYPE_PRECISION (TREE_TYPE (@2)) > && TYPE_PRECISION (TREE_TYPE (@0)) > == TYPE_PRECISION (TREE_TYPE (@3)) > + /* For vect_recog_cond_expr_convert_pattern, @2 and @3 can differ in > + signess when convert is truncation, but not ok for extension since > + it's sign_extend vs zero_extend. */ > + && (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type) > + || (TYPE_UNSIGNED (TREE_TYPE (@2)) > + == TYPE_UNSIGNED (TREE_TYPE (@3)))) > && single_use (@4) > && single_use (@5)))) > diff --git a/gcc/testsuite/gcc.target/i386/pr104551.c b/gcc/testsuite/gcc.target/i386/pr104551.c > new file mode 100644 > index 00000000000..6300f25c0d5 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr104551.c > @@ -0,0 +1,24 @@ > +/* { dg-do run } */ > +/* { dg-options "-O3 -mavx2" } */ > +/* { dg-require-effective-target avx2 } */ > + > +unsigned int > +__attribute__((noipa)) > +test(unsigned int a, unsigned char p[16]) { > + unsigned int res = 0; > + for (unsigned b = 0; b < a; b += 1) > + res = p[b] ? p[b] : (char) b; > + return res; > +} > + > +int main () > +{ > + unsigned int a = 16U; > + unsigned char p[16]; > + for (int i = 0; i != 16; i++) > + p[i] = (unsigned char)128; > + unsigned int res = test (a, p); > + if (res != 128) > + __builtin_abort (); > + return 0; > +} > diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc > index a8f96d59643..217bdfd7045 100644 > --- a/gcc/tree-vect-patterns.cc > +++ b/gcc/tree-vect-patterns.cc > @@ -929,8 +929,10 @@ vect_reassociating_reduction_p (vec_info *vinfo, > with conditions: > 1) @1, @2, c, d, a, b are all integral type. > 2) There's single_use for both @1 and @2. > - 3) a, c and d have same precision. > + 3) a, c have same precision. > 4) c and @1 have different precision. > + 5) c, d are the same type or they can differ in sign when convert is > + truncation. > > record a and c and d and @3. */ > > @@ -952,7 +954,7 @@ extern bool gimple_cond_expr_convert_p (tree, tree*, tree (*)(tree)); > TYPE_PRECISION (TYPE_E) != TYPE_PRECISION (TYPE_CD); > TYPE_PRECISION (TYPE_AB) == TYPE_PRECISION (TYPE_CD); > single_use of op_true and op_false. > - TYPE_AB could differ in sign. > + TYPE_AB could differ in sign when (TYPE_E) A is a truncation. > > Input: > > -- > 2.18.1 >