From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7886) id 59D713853558; Thu, 1 Sep 2022 06:45:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59D713853558 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662014703; bh=Xo8pWQas9gV2fCS9af99LIp/EnCPqUBDDJMZgjxpTOA=; h=From:To:Subject:Date:From; b=KCsNnp8FVNEQolRn+i9Jz663rBTa8P0Uoke/2teHFdpeP5f2seoDetrFrymjDfzb6 RadLfne4Yrdtr8xkneoY4FSCN6e6j/8/j9aRg/duTY50xBOSlp1pJx4WXL0OkqNbxv 8mKyG/NVP2uYg7BbzP6xguX6vCi/yu3SIkIrmDKc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kong Lingling To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2333] middle-end: Add MULT_EXPR recognition for cond scalar reduction X-Act-Checkin: gcc X-Git-Author: konglin1 X-Git-Refname: refs/heads/master X-Git-Oldrev: 023c5b36e476976cb3b45ff32c7c64990c5a6d45 X-Git-Newrev: ca8f4e8af148694ae2fd444a0cdcf713910d23fd Message-Id: <20220901064503.59D713853558@sourceware.org> Date: Thu, 1 Sep 2022 06:45:03 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ca8f4e8af148694ae2fd444a0cdcf713910d23fd commit r13-2333-gca8f4e8af148694ae2fd444a0cdcf713910d23fd Author: konglin1 Date: Thu Sep 1 14:40:42 2022 +0800 middle-end: Add MULT_EXPR recognition for cond scalar reduction gcc/ChangeLog: * tree-if-conv.cc (is_cond_scalar_reduction): Add MULT_EXPR recognition. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/gen-vect-34.c: New test. * gcc.dg/vect/vect-ifcvt-18.c: New test. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c | 16 ++++++++++++ gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c | 38 +++++++++++++++++++++++++++++ gcc/tree-if-conv.cc | 1 + 3 files changed, 55 insertions(+) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c new file mode 100644 index 00000000000..8d2d36401fe --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-34.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-vect-details" } */ +/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */ + +float summul(int n, float *arg1, float *arg2) +{ + int i; + float res1 = 1.0; + for(i = 0; i < n; i++) { + if(arg2[i]) + res1 *= arg1[i]; + } + return res1; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! { avr-*-* pru-*-* } } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c new file mode 100644 index 00000000000..c1d3c27d819 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-Ofast -mavx" { target avx_runtime } } */ + + +int A0[4] = {36,39,42,45}; +int B0[4] = {42,42,0,42}; +float A1[8] = {36,39,42,45,43,32,21,12}; +float B1[8] = {42,42,0,42,42,42,0,42}; +double A2[16] = {36,39,42,45,43,32,21,12,23,34,45,56,42,78,89,11}; +double B2[16] = {42,42,0,42,42,42,42,42,42,42,42,42,0,42,42,42}; + +int main () +{ + int i, j; + int res0 = 1; + float res1 = 1.0; + double res2 = 1.0; + + for (i = 0; i < 4; i++) + if (B0[i]) + res0 *= A0[i]; + + for (i = 0; i < 8; i++) + if (B1[i]) + res1 *= A1[i]; + + for (i = 0; i < 16; i++) + if (B2[i]) + res2 *= A2[i]; + /* check results: */ + if (res0 != 63180 || res1 != 1043228160.000000 + ||res2 != 3296728515318523101184.000000) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 3 loops" "vect" { target i?86-*-* x86_64-*-* } } } */ diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index 1c8e1a45234..bac29fb5574 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -1739,6 +1739,7 @@ is_cond_scalar_reduction (gimple *phi, gimple **reduc, tree arg_0, tree arg_1, if (reduction_op != PLUS_EXPR && reduction_op != MINUS_EXPR + && reduction_op != MULT_EXPR && reduction_op != BIT_IOR_EXPR && reduction_op != BIT_XOR_EXPR && reduction_op != BIT_AND_EXPR)