From patchwork Fri Oct 20 12:13:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 156089 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1010925vqb; Fri, 20 Oct 2023 05:14:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyfXEiWhOepKA2svW3bLpUiNHK2I73WVnkKdAD4B/qfs6C3DnQD4+GHNROHgNworxvTmyd X-Received: by 2002:a05:620a:3907:b0:767:ca49:bacd with SMTP id qr7-20020a05620a390700b00767ca49bacdmr2032708qkn.30.1697804063035; Fri, 20 Oct 2023 05:14:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697804063; cv=pass; d=google.com; s=arc-20160816; b=J7vv2SakDDDm+LK/1MFj9FOLoRAtiYevb4zc5p8ctofBxhGXaULq+1fnzPfyR0iy3e PuOE4Q+I/M/G7Nt3R1y4mmcg6JGhQbVpyZTl94G+HMHdXAFdwjetwL+HjvhqZMk6EOYC hdVtwF6gEX9HYwsintD01VRAh7rYB/AQnhdjI4/ZkzT79ZiH6SUuJAac1QUAoPqonb5n yMg0EfmK0OugDX9r3PkugbDx/3j32S1GlwgmIVN2129OA+Ri4Rb/RYVEF6VFvSgWVfFZ hHiDtSeImI7Pq5bqprOCEozbd/wUuuJrY4mU1Ncjx0dltp6z2KE4GDmTJJIrhjphMxSG VNcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:mime-version:subject :to:from:date:dkim-signature:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=bPflk+ynvi0iDkB2koVwVUHeEGErS586GBq+AnMQhdM=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=D/TUc9x/1MSJ0AZ5+6iRq1wq0n4zDgCn+xSEsiGx5rCEE5wzrXYQGF7a/GB2zRAnLZ 1j7++Zq3tmLxVRxG8DNeHg7Vo4Qe5I0Ps8CCAA4LtZzXAIVGo3vJsBFKDmhYRnUVmUUq K/U2Q/Olr2tnYcrbKVQoBEyKrH09CCiZ27poTRHAToqmt2O/RuTCGIiyeeARZeRfmSBK xZFeCQK4vB5N4huayKLY0gNeNZa7Uo0Ls5uMCfoqGARuio5eleNLTtFbU6HJSc9GeICh th3S5y1/3HSrSC3fMFyH6tNrIYe0VREB87PPbiCAc6EnSIcsjoAv8PU0lf9ner78L2f9 BK5g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="q/QfzI4C"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h28-20020a05620a13fc00b007756b12c2eesi1121343qkl.26.2023.10.20.05.14.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 05:14:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="q/QfzI4C"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C86763858416 for ; Fri, 20 Oct 2023 12:14:22 +0000 (GMT) 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 [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 30587385843E for ; Fri, 20 Oct 2023 12:13:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30587385843E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 30587385843E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697804040; cv=none; b=mbak/tcES+413C75+O+5+9QIsjJw9GTfMQMYlUOKKiOmbacJYSIHPRq2Gg4mVhUO0OT5Hbeagdj5Tm70cOLSh99oEqDPFooJtnrf0UB5X7CqWKumDwBu3cEwTsOC4shCrGIwGNTAAEy14akaeAZeEFlZUX6SzdmsoRR8qwv8qrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697804040; c=relaxed/simple; bh=6/kV8bjGU0Ztpl5U4mo9xTITSk1MtYh2Jvu/dwsO0+s=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version: Message-Id; b=by3ClmIUMiIyiVcKtBCvpWA7+H19sc5I9cO2uZVWqP+DsGHgypQwebop8oQWHgalni6dXbjXSyYd9XhVkHLG44+RuCobYFekYFLraY+xxGb3NAmG4mpRh1quHlg29GUuoZ8zWFxl5RCD//3niWpVtKAN/27+Iq47yStUYDi1Rc4= ARC-Authentication-Results: i=1; server2.sourceware.org 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 B2FF21F8A3 for ; Fri, 20 Oct 2023 12:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1697804037; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=bPflk+ynvi0iDkB2koVwVUHeEGErS586GBq+AnMQhdM=; b=q/QfzI4C7UTWt3wzbXyyEcpMZp8hKokihKchv7nE8cprmzAala21HIz9mHiLyR6KxnJUHV ZIoleSmG/yAE9hP6LLeff1r4IKV5tic9csN9a/BpjBE4+AxHCbqnkPvdATcnS3D1v+xo/X FY5+T6jGyYzGn/AdVXgt14o3MMeEUEE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1697804037; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=bPflk+ynvi0iDkB2koVwVUHeEGErS586GBq+AnMQhdM=; b=UwfMHFDBNHQhcNAMdjrrn238p0p4ID1B9jNvhTvDNqsLJncl68FRgnwwhD/1NlZVcn80uh XR66PClMF/fnZxBA== 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 9F55713584 for ; Fri, 20 Oct 2023 12:13:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bq+zJQVvMmVZAgAAMHmgww (envelope-from ) for ; Fri, 20 Oct 2023 12:13:57 +0000 Date: Fri, 20 Oct 2023 14:13:57 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/111891 - fix assert in vectorizable_simd_clone_call MIME-Version: 1.0 Message-Id: <20231020121357.9F55713584@imap2.suse-dmz.suse.de> Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -7.10 X-Spamd-Result: default: False [-7.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-11.2 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780276593341184202 X-GMAIL-MSGID: 1780276593341184202 The following fixes the assert in vectorizable_simd_clone_call to assert we have a vector type during transform. Whether we have one during analysis depends on whether another SLP user decided on the type of a constant/external already. When we end up with a mismatch in desire the updating will fail and make vectorization fail. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/111891 * tree-vect-stmts.cc (vectorizable_simd_clone_call): Fix assert. * gfortran.dg/pr111891.f90: New testcase. --- gcc/testsuite/gfortran.dg/pr111891.f90 | 21 +++++++++++++++++++++ gcc/tree-vect-stmts.cc | 8 +++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr111891.f90 diff --git a/gcc/testsuite/gfortran.dg/pr111891.f90 b/gcc/testsuite/gfortran.dg/pr111891.f90 new file mode 100644 index 00000000000..1167ed60f4c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr111891.f90 @@ -0,0 +1,21 @@ +! { dg-do compile } +! { dg-options "-O2" } +! { dg-additional-options "-mavx" { target avx } } + +!GCC$ builtin (powf) attributes simd (notinbranch) if('x86_64') + +PARAMETER (NX=3, G=1.4) +DIMENSION T(NX,NX), P(NX,NX) +INTEGER Apx +COMMON P, T + +DO i = 1, 3 + IF (i < 0.0 ) THEN + P(Apx,i) = i**G + T(Apx,i) = i**G + ELSE + P(Apx,i) = 0 + T(Apx,i) = 0 + ENDIF +ENDDO +END diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 8d9028654c9..337b24c51f9 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -4070,7 +4070,13 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info, if (thisarginfo.dt == vect_constant_def || thisarginfo.dt == vect_external_def) { - gcc_assert (vec_stmt || thisarginfo.vectype == NULL_TREE); + /* With SLP we determine the vector type of constants/externals + at analysis time, handling conflicts via + vect_maybe_update_slp_op_vectype. At transform time + we have a vector type recorded for SLP. */ + gcc_assert (!vec_stmt + || !slp_node + || thisarginfo.vectype != NULL_TREE); if (!vec_stmt) thisarginfo.vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op),