From patchwork Fri May 29 08:51:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1300549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=DT4Eyoah; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49YJGM4ZKMz9sT4 for ; Fri, 29 May 2020 18:51:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33C00397CF2D; Fri, 29 May 2020 08:51:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33C00397CF2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590742301; bh=BHBYtFcdWkVz9G9lNPbxC2K5hRUOaYWkpIu9mO+SwBk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DT4EyoahcB253+7nppbP+BSzFEZu4wdGNcw1wvRJ46l2Ti3uS8epSYlX0vApQ2eBO X1Sq19AN66PfdyN+rniLW6Spr47bH45fpfKA6AVLJFYvU3rzjbeLrNtVpPUEwTFTLN XtaG+/XCTlE84CHiLb8MErC3WwgKKPNvr+AMIqT0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id AECE83851C2A for ; Fri, 29 May 2020 08:51:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AECE83851C2A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-CjD5ACJjNqic9oXegeT8qQ-1; Fri, 29 May 2020 04:51:37 -0400 X-MC-Unique: CjD5ACJjNqic9oXegeT8qQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D996C64AD8 for ; Fri, 29 May 2020 08:51:36 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-94.ams2.redhat.com [10.36.112.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 865116298C for ; Fri, 29 May 2020 08:51:36 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 04T8pXrL026507 for ; Fri, 29 May 2020 10:51:34 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 04T8pXxo026503 for gcc-patches@gcc.gnu.org; Fri, 29 May 2020 10:51:33 +0200 Date: Fri, 29 May 2020 10:51:33 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: One omp_resolve_declare_variant followup [PR95315] Message-ID: <20200529085133.GI8462@tucnak> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-9.4 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_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! As noticed by Arseny, I got the condition when to call the add removal hook wrong wrong. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2020-05-28 Jakub Jelinek PR middle-end/95315 * omp-general.c (omp_resolve_declare_variant): Fix up addition of declare variant cgraph node removal callback. * gcc.dg/gomp/pr95315-2.c: New test. Jakub --- gcc/omp-general.c.jj 2020-05-27 10:25:35.855578064 +0200 +++ gcc/omp-general.c 2020-05-28 19:39:38.575186925 +0200 @@ -1851,7 +1851,7 @@ omp_resolve_declare_variant (tree base) } static struct cgraph_node_hook_list *node_removal_hook_holder; - if (node_removal_hook_holder) + if (!node_removal_hook_holder) node_removal_hook_holder = symtab->add_cgraph_removal_hook (omp_declare_variant_remove_hook, NULL); --- gcc/testsuite/gcc.dg/gomp/pr95315-2.c.jj 2020-05-28 19:41:26.765630849 +0200 +++ gcc/testsuite/gcc.dg/gomp/pr95315-2.c 2020-05-28 19:32:34.511286132 +0200 @@ -0,0 +1,46 @@ +/* PR middle-end/95315 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp --param ggc-min-heapsize=0" } */ + +typedef float __v4sf __attribute__((vector_size (16))); +typedef int __v4si __attribute__((vector_size (16))); +typedef float __v8sf __attribute__((vector_size (32))); +typedef int __v8si __attribute__((vector_size (32))); +__v4si f1 (__v4sf, __v4sf, float *); +__v8si f2 (__v8sf, __v8sf, float *); +__v4si f3 (__v4si, int, __v4si); + +#pragma omp declare variant (f1) match (construct={parallel,for,simd(simdlen(4),notinbranch,uniform(z),aligned(z:4 * sizeof (*z)))}) +#pragma omp declare variant (f2) match (construct={for,simd(uniform(z),simdlen(8),notinbranch)}) +int f4 (float x, float y, float *z); + +#pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))}) +int f5 (int x, int y); + +static inline __attribute__((always_inline)) int +ret_false (void) +{ + return 0; +} + +void +test (int *x, float *y, float *z, float *w) +{ + #pragma omp parallel + #pragma omp for simd aligned (w:4 * sizeof (float)) + for (int i = 0; i < 1024; i++) + if (ret_false ()) + x[i] = f4 (y[i], z[i], w); + #pragma omp parallel for simd aligned (w:4 * sizeof (float)) simdlen(4) + for (int i = 1024; i < 2048; i++) + if (ret_false ()) + x[i] = f4 (y[i], z[i], w); + #pragma omp simd aligned (w:4 * sizeof (float)) + for (int i = 2048; i < 4096; i++) + if (ret_false ()) + x[i] = f4 (y[i], z[i], w); + #pragma omp simd + for (int i = 4096; i < 8192; i++) + if (x[i] > 10 && ret_false ()) + x[i] = f5 (x[i], i); +}