Message ID | 200bdb15-2621-2ba3-fc04-5fd20821f871@suse.cz |
---|---|
State | Not Applicable |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2158051vqo; Mon, 3 Apr 2023 02:03:14 -0700 (PDT) X-Google-Smtp-Source: AKy350aZx7PUUpHOWJhyqeVKB+Wks1giIxYZnHgQ/1+Mb0TUjoa4Jcq8y1Z0GbvHp3jKkUaSb54x X-Received: by 2002:a17:907:7b8d:b0:946:c265:7931 with SMTP id ne13-20020a1709077b8d00b00946c2657931mr28740133ejc.59.1680512594118; Mon, 03 Apr 2023 02:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680512594; cv=none; d=google.com; s=arc-20160816; b=iEbJ+cTb0rSBeHE9Yuq/kwoU3IXWsGDsNR+q1rSj3CbSIMxohKHMFxvo9otfnifyYP 1JnZIGkg0BXXVujQKZiOWrG6zetzR15d9ZT5Ss43Up58RGsIazzSGy3JuRx2Q8w/T1v6 t7xv5W4/UE7Dlvn6uge3i8Ufu+P15fDFnpF4BZmkYaLKmCfCIqw9n7ppSKccimLcxArG aXVaWJreiFhWFw5vuZVfsE3RxVGqNmAjukeQmhzJ5WkihBJaKSHsUXTs0SDRf3183ynr j+1fTU7s6sc3x7sj7JwtaSRTpunVOkapjEC2dOFWlBWp6DzfFEdA3JOHCk3Ys0m1zwaK UpCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc :content-language:to:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=H/XfQd8fVtvMaYRJ3MqFrh063YV2myWVKykIZT6ZM7U=; b=JXIfJQnz9QOV7BPxr8AGyZrnmoBv38Gvp7wrJgWY8mQRKwQqxADCNjF8OEFvUrx2yq 6YSnZvPblt+3vFXl/UDxkgIDlEYk3dHLFXUJFUjrGpp/qpEHugvFLkNraKlvYLLPYu7p 2jz7jeljsn2dhs2szf4GZoLdd+K47gqdi+cEskBmetRGm2dCQzPGoJoV9otZmAnA3/sv dYJmHPKuufkUKaUUKkUia3XD2w7JUR64T8Bl24qn9xPlEa1H2v/4eCYmcuirXrxoNH6C CZthEPydiHdaxb6ChLrWCj+VXNsPwgTMO56keJnkdsdp/OaOX75M5f40cVsrOSyMFW09 kixw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Ci6POTyK; dkim=neutral (no key) header.i=@gcc.gnu.org header.s=susede2_ed25519 header.b=exZeugFN; 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" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a19-20020a1709064a5300b00946bd53bbc8si2406105ejv.403.2023.04.03.02.03.13 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 02:03:14 -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.cz header.s=susede2_rsa header.b=Ci6POTyK; dkim=neutral (no key) header.i=@gcc.gnu.org header.s=susede2_ed25519 header.b=exZeugFN; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE9A63854839 for <ouuuleilei@gmail.com>; Mon, 3 Apr 2023 09:03:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 3ECE53858D39 for <gcc-patches@gcc.gnu.org>; Mon, 3 Apr 2023 09:02:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3ECE53858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz 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-out1.suse.de (Postfix) with ESMTPS id 061A121B3A; Mon, 3 Apr 2023 09:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1680512553; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=H/XfQd8fVtvMaYRJ3MqFrh063YV2myWVKykIZT6ZM7U=; b=Ci6POTyKFAqhw+vrst39Tw5UAhpBsu90IffX1eAvk43gSbZCq7fPDVKvd6ryXVYflgGiSQ C4ZYStZB2QJC8IPxFGYe+CL98pMW/4TZir/sRQU+MRDpca7J2A3zlQMw10xpluQBo23F7h PPmh8vy2mIaMHZOhMZ/ELYzAe//pl2Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1680512553; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=H/XfQd8fVtvMaYRJ3MqFrh063YV2myWVKykIZT6ZM7U=; b=exZeugFNvqJrZmpMRpF3CYPOWqrwyM2Jl+piycRG/BM/gdHSiE3sn7R4rhekoLmsBKtNkB DcqOFMA8QsR+Q1AQ== 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 E892B13416; Mon, 3 Apr 2023 09:02:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 39qrNyiWKmTIVQAAMHmgww (envelope-from <mliska@suse.cz>); Mon, 03 Apr 2023 09:02:32 +0000 Message-ID: <200bdb15-2621-2ba3-fc04-5fd20821f871@suse.cz> Date: Mon, 3 Apr 2023 11:02:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= <mliska@suse.cz> Subject: [PATCH] ipa: propagate attributes for target attribute clones To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: "H.J. Lu" <hjl.tools@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_SOFTFAIL, 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.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762145173739928960?= X-GMAIL-MSGID: =?utf-8?q?1762145173739928960?= |
Series |
ipa: propagate attributes for target attribute clones
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | fail | Git am fail log |
Commit Message
Martin Liška
April 3, 2023, 9:02 a.m. UTC
Hi. The patch propagates noreturn attribute for MV functions. However, I noticed we've got the following ICE when we do the same for TREE_READONLY attr: $ cat tc.c double bar() __attribute__((target_clones("avx,avx2,avx512f,default"))); double bar() { return 1.2f; } int foo() { return (int)bar(); } $ ./xgcc -B. ~/Programming/testcases/tc.c -O3 -c -fprofile-generate /home/marxin/Programming/testcases/tc.c: In function ‘foo’: /home/marxin/Programming/testcases/tc.c:4:5: error: virtual definition of statement not up to date 4 | int foo() { return (int)bar(); } | ^~~ _1 = bar (); during GIMPLE pass: fixup_cfg Thus my ambition is to propagate only noreturn attr. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR ipa/106816 gcc/ChangeLog: * config/i386/i386-features.cc (ix86_get_function_versions_dispatcher): Propagate function attributes for clones. gcc/testsuite/ChangeLog: * g++.target/i386/pr106816.C: New test. Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> --- gcc/config/i386/i386-features.cc | 1 + gcc/testsuite/g++.target/i386/pr106816.C | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.target/i386/pr106816.C
Comments
On Mon, Apr 3, 2023 at 11:03 AM Martin Liška <mliska@suse.cz> wrote: > > Hi. > > The patch propagates noreturn attribute for MV functions. However, I noticed > we've got the following ICE when we do the same for TREE_READONLY attr: > > $ cat tc.c > double bar() __attribute__((target_clones("avx,avx2,avx512f,default"))); > double bar() { return 1.2f; } > > int foo() { return (int)bar(); } > > $ ./xgcc -B. ~/Programming/testcases/tc.c -O3 -c -fprofile-generate > /home/marxin/Programming/testcases/tc.c: In function ‘foo’: > /home/marxin/Programming/testcases/tc.c:4:5: error: virtual definition of statement not up to date > 4 | int foo() { return (int)bar(); } > | ^~~ > _1 = bar (); > during GIMPLE pass: fixup_cfg > > Thus my ambition is to propagate only noreturn attr. But wouldn't that mean the IL needs fixup for the call to the dispatcher which would be non-const for actually const implementations? That said, maybe the IPA cloning for the actual functions need adjustments as well? > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > PR ipa/106816 > > gcc/ChangeLog: > > * config/i386/i386-features.cc (ix86_get_function_versions_dispatcher): > Propagate function attributes for clones. > > gcc/testsuite/ChangeLog: > > * g++.target/i386/pr106816.C: New test. > > Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> > --- > gcc/config/i386/i386-features.cc | 1 + > gcc/testsuite/g++.target/i386/pr106816.C | 23 +++++++++++++++++++++++ > 2 files changed, 24 insertions(+) > create mode 100644 gcc/testsuite/g++.target/i386/pr106816.C > > diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc > index c09abf8fc20..f2b0d59a73c 100644 > --- a/gcc/config/i386/i386-features.cc > +++ b/gcc/config/i386/i386-features.cc > @@ -3379,6 +3379,7 @@ ix86_get_function_versions_dispatcher (void *decl) > /* Right now, the dispatching is done via ifunc. */ > dispatch_decl = make_dispatcher_decl (default_node->decl); > TREE_NOTHROW (dispatch_decl) = TREE_NOTHROW (fn); > + TREE_THIS_VOLATILE (dispatch_decl) = TREE_THIS_VOLATILE (fn); > > dispatcher_node = cgraph_node::get_create (dispatch_decl); > gcc_assert (dispatcher_node != NULL); > diff --git a/gcc/testsuite/g++.target/i386/pr106816.C b/gcc/testsuite/g++.target/i386/pr106816.C > new file mode 100644 > index 00000000000..0f5cc1f13dd > --- /dev/null > +++ b/gcc/testsuite/g++.target/i386/pr106816.C > @@ -0,0 +1,23 @@ > +// PR ipa/106816 > + > +// { dg-do compile } > +// { dg-require-ifunc "" } > +// { dg-options "-O2 -fdump-tree-optimized" } > + > +__attribute__((noreturn, target("default"))) void f() > +{ > + for (;;) {} > +} > + > +__attribute__((noreturn, target("sse4.2,bmi"))) void f() > +{ > + for (;;) {} > +} > + > +int main() > +{ > + f(); > + return 12345; > +} > + > +/* { dg-final { scan-tree-dump-not "12345" "optimized" } } */ > -- > 2.40.0 >
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index c09abf8fc20..f2b0d59a73c 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -3379,6 +3379,7 @@ ix86_get_function_versions_dispatcher (void *decl) /* Right now, the dispatching is done via ifunc. */ dispatch_decl = make_dispatcher_decl (default_node->decl); TREE_NOTHROW (dispatch_decl) = TREE_NOTHROW (fn); + TREE_THIS_VOLATILE (dispatch_decl) = TREE_THIS_VOLATILE (fn); dispatcher_node = cgraph_node::get_create (dispatch_decl); gcc_assert (dispatcher_node != NULL); diff --git a/gcc/testsuite/g++.target/i386/pr106816.C b/gcc/testsuite/g++.target/i386/pr106816.C new file mode 100644 index 00000000000..0f5cc1f13dd --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr106816.C @@ -0,0 +1,23 @@ +// PR ipa/106816 + +// { dg-do compile } +// { dg-require-ifunc "" } +// { dg-options "-O2 -fdump-tree-optimized" } + +__attribute__((noreturn, target("default"))) void f() +{ + for (;;) {} +} + +__attribute__((noreturn, target("sse4.2,bmi"))) void f() +{ + for (;;) {} +} + +int main() +{ + f(); + return 12345; +} + +/* { dg-final { scan-tree-dump-not "12345" "optimized" } } */