From patchwork Tue Apr 30 07:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1929359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=P8pIuARx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VTBnk66kBz23jG for ; Tue, 30 Apr 2024 17:35:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 10E8F385842C for ; Tue, 30 Apr 2024 07:35:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BF0E3385E83A for ; Tue, 30 Apr 2024 07:35:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF0E3385E83A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BF0E3385E83A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714462531; cv=none; b=EL257klQlvDlHIaBkux+aRR5gQaujPuXznnNkNucVqYfGEy06ZI/deM7isrQTLIRdkf9MnahWaRAEtY/bEKvbOjHa046/HqG5MvY1mI/y3OeLEXc7ijBFejzbYwt8Qk30i6JJ3nokuessRJVkoO232dS+c67cZrykKqSENJUmHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714462531; c=relaxed/simple; bh=U43Gb7gNdm2xr4tEY7H79efTlnvFf7RV3iPAsugx5O8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=DhosOaRG+Dy0WgduHkY0EmJl2pQJLlVv6xQOmFPXEo2n90MNoCEj2loZpfaUp1pquDHdL6M6dBdYq60i7l3EpO/FT0b2/p0ld5XxdI+xYc9y8DWwld+m+lK5oQt9SPiw+7DkzR4xBtqveYHoVvZo39NdKz62e0B4m5qCKKDk+dk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714462529; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=gYtZwbHQp1bEZI0vr3dUJpxtThQKCBkDzOtT+VW0u94=; b=P8pIuARxWScmNm9c/4k/4Eo5rwpubTnYRS5CndPc4g3pJcd1B8Si0rqq0TMAo2N9VikTok BOJ1sfrcj/w4pZSLcuD8h5JYsGihLFWtKzpiW3vhFVgKH69++y3kSPaNmA8GsbKWMGA2Tl Gg9LLajJPetA1MwSIyoR0QcWqlfi7T0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169--OEbr7mdP7GU-5y6jAnD5g-1; Tue, 30 Apr 2024 03:35:25 -0400 X-MC-Unique: -OEbr7mdP7GU-5y6jAnD5g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88CF33806738; Tue, 30 Apr 2024 07:35:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B4932166B31; Tue, 30 Apr 2024 07:35:25 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 43U7ZNMe2788821 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 30 Apr 2024 09:35:24 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 43U7ZNTB2788820; Tue, 30 Apr 2024 09:35:23 +0200 Date: Tue, 30 Apr 2024 09:35:23 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] vect: Adjust vect_transform_reduction assertion [PR114883] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! The assertion doesn't allow IFN_COND_MIN/IFN_COND_MAX, which are commutative conditional binary operations like ADD/MUL/AND/IOR/XOR, and can be handled just fine. In particular, we emit vminpd %zmm3, %zmm5, %zmm0{%k2} vminpd %zmm0, %zmm3, %zmm5{%k1} and vmaxpd %zmm3, %zmm5, %zmm0{%k2} vmaxpd %zmm0, %zmm3, %zmm5{%k1} in the vectorized loops of the first and second subroutine. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and 14.1? 2024-04-30 Jakub Jelinek Hongtao Liu PR tree-optimization/114883 * tree-vect-loop.cc (vect_transform_reduction): Allow IFN_COND_MIN and IFN_COND_MAX in the assert. * gfortran.dg/pr114883.f90: New test. Jakub --- gcc/tree-vect-loop.cc.jj 2024-04-17 11:34:02.465185397 +0200 +++ gcc/tree-vect-loop.cc 2024-04-29 20:41:04.973723992 +0200 @@ -8505,7 +8505,8 @@ vect_transform_reduction (loop_vec_info { gcc_assert (code == IFN_COND_ADD || code == IFN_COND_SUB || code == IFN_COND_MUL || code == IFN_COND_AND - || code == IFN_COND_IOR || code == IFN_COND_XOR); + || code == IFN_COND_IOR || code == IFN_COND_XOR + || code == IFN_COND_MIN || code == IFN_COND_MAX); gcc_assert (op.num_ops == 4 && (op.ops[reduc_index] == op.ops[internal_fn_else_index ((internal_fn) code)])); --- gcc/testsuite/gfortran.dg/pr114883.f90.jj 2024-04-29 20:39:39.000871849 +0200 +++ gcc/testsuite/gfortran.dg/pr114883.f90 2024-04-29 20:39:27.757021972 +0200 @@ -0,0 +1,53 @@ +! PR tree-optimization/114883 +! { dg-do compile } +! { dg-options "-O2 -fvect-cost-model=cheap" } +! { dg-additional-options "-march=x86-64-v4" { target i?86-*-* x86_64-*-* } } + +subroutine pr114883_1(a, b, c, d, e, f, g, h, o) + real(8) :: c(1011), d(1011), e(0:1011) + real(8) :: p, q, f, r, g(1011), h(1011), b, bar + integer :: o(100), a, t, u + p = 0.0_8 + r = bar() + u = 1 + do i = 1,a + do k = 1,1011 + km1 = max0(k-1,1) + h(k) = c(k) * e(k-1) * d(km1) + f = g(k) + h(k) + if(f.gt.1.e-6)then + p = min(p,r) + endif + end do + q = 0.9_8 * p + t = integer(b/q + 1) + if(t>100)then + u = t + endif + o(u) = o(u) + 1 + end do +end subroutine pr114883_1 +subroutine pr114883_2(a, b, c, d, e, f, g, h, o) + real(8) :: c(1011), d(1011), e(0:1011) + real(8) :: p, q, f, r, g(1011), h(1011), b, bar + integer :: o(100), a, t, u + p = 0.0_8 + r = bar() + u = 1 + do i = 1,a + do k = 1,1011 + km1 = max0(k-1,1) + h(k) = c(k) * e(k-1) * d(km1) + f = g(k) + h(k) + if(f.gt.1.e-6)then + p = max(p,r) + endif + end do + q = 0.9_8 * p + t = integer(b/q + 1) + if(t>100)then + u = t + endif + o(u) = o(u) + 1 + end do +end subroutine pr114883_2