From patchwork Tue May 18 16:02:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1480346 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4Fl14Z1Tqcz9sW8 for ; Wed, 19 May 2021 02:03:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 551B03835420; Tue, 18 May 2021 16:03:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 698B03850403 for ; Tue, 18 May 2021 16:03:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 698B03850403 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Thomas_Schwinge@mentor.com IronPort-SDR: mtbyioS30gnyXwSzJvCZRKHzKCdpj2RsATwOMsIOa04no9FUXwXDMC/veVRCvlGFRyfsdwkLWL JQsiiJ+SbGudgWyl1mYCp9Wvg5s4bVf4KWHsg+15kv/5nSvm1TGBQE1/BHFdFrtMHlk0FUeZdC 21eIyOgxeIUU0S74AjDQEiR4SNLMkhMrHtbTDAfc8UED3YUeNEyjIeNIUvN/zWIFfeExLz3BW/ 436bBVv5L31otLS6RiMBZQcn5P9Cp5asf+J67a7nAg5SC/lNO2hLunfr1dDUXuzuKpuyRx4rOy cWo= X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208,223";a="61346835" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 18 May 2021 08:03:03 -0800 IronPort-SDR: Dz2RyOPz+hn9XBdb8GoPsVBaHtGBY6KPo500CU6iTg9JNMNP5dc9i3q978CRqnxJoeOmuzvYB2 r3DUQC0cnC8otlJfE3fibC8oENGkY7BiQyKLfcQR7Sq57FWuOp/874qBHmgEGU2JYE79th1qAJ gCMjw2vMwe742A9Ff1ACHo94PwJVvh3myXx5e8hbgPIMZX+3p1RGfeBkl+Qa2YY12+smXqVSWE J80RHlk6v6yl1JsxEqBCTaChR6Hj9xYd/85RBLUSITagTArbfhcWz5iSU0L9XhKqY7U+7zCPVI AaA= From: Thomas Schwinge To: Subject: Add '__OPTIMIZE__' DejaGnu selector User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Tue, 18 May 2021 18:02:56 +0200 Message-ID: <87cztoc9n3.fsf@dem-tschwing-1.ger.mentorg.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! Is the attached "Add '__OPTIMIZE__' DejaGnu selector" OK to push after testing? Grüße Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf From f2228df26acc3036357debfb5b08501047b78756 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 18 May 2021 17:30:34 +0200 Subject: [PATCH] Add '__OPTIMIZE__' DejaGnu selector gcc/testsuite/ * lib/target-supports.exp (check_effective_target___OPTIMIZE__): New proc. * gcc.c-torture/compile/ssa-unused-1.c: New file. gcc/ * doc/sourcebuild.texi (Other attributes): Document '__OPTIMIZE__' DejaGnu selector. --- gcc/doc/sourcebuild.texi | 4 ++++ .../gcc.c-torture/compile/ssa-unused-1.c | 15 +++++++++++++++ gcc/testsuite/lib/target-supports.exp | 10 ++++++++++ 3 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/ssa-unused-1.c diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index ed811d103a5..cf3098749c0 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2755,6 +2755,10 @@ constant. @item lgccjit Target supports -lgccjit, i.e. libgccjit.so can be linked into jit tests. + +@item __OPTIMIZE__ +Optimizations are enabled (@code{__OPTIMIZE__}) per the current +compiler flags. @end table @subsubsection Local to tests in @code{gcc.target/i386} diff --git a/gcc/testsuite/gcc.c-torture/compile/ssa-unused-1.c b/gcc/testsuite/gcc.c-torture/compile/ssa-unused-1.c new file mode 100644 index 00000000000..e8fb93c74c2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/ssa-unused-1.c @@ -0,0 +1,15 @@ +/* This is just to exercise the '__OPTIMIZE__' DejaGnu selector. */ + +/* { dg-do "assemble" } */ +/* { dg-additional-options "-fdump-tree-ssa" } */ + +void f() +{ + int unused = 3; + (void) &unused; +} + +/* { dg-final { scan-tree-dump-not {No longer having address taken: unused} ssa { target { ! __OPTIMIZE__ } } } } + { dg-final { scan-tree-dump-times {No longer having address taken: unused} 1 ssa { target __OPTIMIZE__ } } } */ +/* { dg-final { scan-tree-dump-not {Now a gimple register: unused} ssa { target { ! __OPTIMIZE__ } } } } + { dg-final { scan-tree-dump-times {Now a gimple register: unused} 1 ssa { target __OPTIMIZE__ } } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 8192da5ec9f..849f1bbeda5 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -11103,3 +11103,13 @@ proc check_effective_target_lra { } { return 1 } +# Test whether optimizations are enabled ('__OPTIMIZE__') per the +# 'current_compiler_flags' (thus don't cache). + +proc check_effective_target___OPTIMIZE__ {} { + return [check_no_compiler_messages_nocache __OPTIMIZE__ assembly { + #ifndef __OPTIMIZE__ + # error nein + #endif + } [current_compiler_flags]] +} -- 2.25.1