From patchwork Mon Apr 4 09:34:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 52611 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 98D9C3858413 for ; Mon, 4 Apr 2022 09:36:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98D9C3858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649064964; bh=p4tZFwL31Q+hAgYfcpv55fTSTs24g5v7RvTLh9l1ms8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oSwZWQvEpcQOiOiQ8PURTQif2IObBDRQ7rMMEWrVxz1+OhfzSA35Z5rpA8dn5f2GK 8V5eHXSQlWaxv2DvHbswWS8h85ivrQPoYEegcBOHZdy09PPkRPHf/LO+IJ4gFUh1oC PUOd33zgXIbKBe6FeWO3rLMA53qFtVPOM6Bdnq4o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 4DECF3858427 for ; Mon, 4 Apr 2022 09:34:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4DECF3858427 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 88A1C1F380 for ; Mon, 4 Apr 2022 09:34:09 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 75DB713216 for ; Mon, 4 Apr 2022 09:34:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id p7qdG5G7SmI8JgAAMHmgww (envelope-from ) for ; Mon, 04 Apr 2022 09:34:09 +0000 Date: Mon, 4 Apr 2022 11:34:09 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105132 - add missing checking in vectorizable_operation MIME-Version: 1.0 Message-Id: <20220404093409.75DB713216@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The following adds missing verification that the input vectors have the same number of elements for vectorizable_operation. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2022-04-04 Richard Biener PR tree-optimization/105132 * tree-vect-stmts.cc (vectorizable_operation): Check that the input vectors have the same number of elements. * gcc.dg/torture/pr105132.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr105132.c | 12 ++++++++++++ gcc/tree-vect-stmts.cc | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr105132.c diff --git a/gcc/testsuite/gcc.dg/torture/pr105132.c b/gcc/testsuite/gcc.dg/torture/pr105132.c new file mode 100644 index 00000000000..f8f0b16ec56 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr105132.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */ + +short a; +extern int b[]; +int c; +void d(long f[][5][5][17], int g[][5][5][17]) { + for (short e = 0; e < 17; e++) { + a = g[19][2][3][e]; + b[e] = c & (f[3][2][3][e] && g[19][2][3][e]); + } +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index f7449a79d1c..f6fc7e1fcdd 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6133,6 +6133,9 @@ vectorizable_operation (vec_info *vinfo, "use not simple.\n"); return false; } + if (vectype2 + && maybe_ne (nunits_out, TYPE_VECTOR_SUBPARTS (vectype2))) + return false; } if (op_type == ternary_op) { @@ -6144,6 +6147,9 @@ vectorizable_operation (vec_info *vinfo, "use not simple.\n"); return false; } + if (vectype3 + && maybe_ne (nunits_out, TYPE_VECTOR_SUBPARTS (vectype3))) + return false; } /* Multiple types in SLP are handled by creating the appropriate number of