From patchwork Fri Jul 30 13:04:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1511658 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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=rXTOczvJ; dkim-atps=neutral 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 4GbngJ09cjz9sT6 for ; Fri, 30 Jul 2021 23:04:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22DF9386483B for ; Fri, 30 Jul 2021 13:04:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22DF9386483B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627650294; bh=WBOzONTQtM+ImvpiMzbNYieA5JoI8TA8uiPGCJmnevc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=rXTOczvJrSUY/7KyPYEXPkOE8ByP3Ggb1cQ5oPdVrbnScjM1bjJIMULKKIG7O2Ps/ LxTSIZMvA6inz9AQm4XrC4Q7iBEMshfFQwyHyRFVsJgJc6kHZaHhx2JLDUh0QgAGcD sw5PqjLSP36mWnhmFNMacjsrr+kb2j8a1laK5B7U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 0F0A33858426 for ; Fri, 30 Jul 2021 13:04:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F0A33858426 Received: by mail-pj1-x1030.google.com with SMTP id ca5so15021085pjb.5 for ; Fri, 30 Jul 2021 06:04:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WBOzONTQtM+ImvpiMzbNYieA5JoI8TA8uiPGCJmnevc=; b=SkL9atBnWYtA1YEJOqLqeORmK6FN/SiNZh6c8CT26Je2uCezkB4h8pNprM0xzLccbc ZFMygIfyn/vOd8bIf4/+WZre+2V+J7CciJwENDHfiRg3DYc+CE/KyfiHfVVfSxjpCj8k jjiolZZC2wnn5kvpdFKo9uNiO5b9yytol6+4JKEAEec1PvMGTXnMne5BcPtzKFN0/M8Y bJ5huUAsqpoAeZldPdJj44DQ/a1m6MrlP4QIVU/VqYCc4OMXipQ9zoiruwY+uTOqlAIJ 2cH0hkpSyNS0+ACKqSUtd3A1kIY5jbKjYV//Ch4ItDKpTQsHfXisOi1Rb43OhXOpa87T OjLQ== X-Gm-Message-State: AOAM533EoTjSfjWTxcm3wDKpB4y6ci6Bvm9BSIUVTu2no7TbvYbyj3yj i5ssScUO9+kJ5Q6a3fWvgqv1AbtT/v4= X-Google-Smtp-Source: ABdhPJwV0hJ02c0bM34511oDnW9z4zpy9YVI2pmge+exD9UfIUFeE3Wc3PRpXNevlgL8wQznXUxXnA== X-Received: by 2002:a62:1d06:0:b029:3ab:9703:b6b8 with SMTP id d6-20020a621d060000b02903ab9703b6b8mr2655730pfd.0.1627650248917; Fri, 30 Jul 2021 06:04:08 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id o134sm2412641pfg.62.2021.07.30.06.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 06:04:08 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 57725C007F; Fri, 30 Jul 2021 06:04:07 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] x86: Don't enable LZCNT/POPCNT if disabled explicitly Date: Fri, 30 Jul 2021 06:04:07 -0700 Message-Id: <20210730130407.1733336-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3033.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" gcc/ PR target/101685 * config/i386/i386-options.c (ix86_option_override_internal): Don't enable LZCNT/POPCNT if they have been disabled explicitly. gcc/testsuite/ PR target/101685 * gcc.target/i386/pr-101685.c: New test. --- gcc/config/i386/i386-options.c | 6 ++++-- gcc/testsuite/gcc.target/i386/pr-101685.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr-101685.c diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c index 3416a4f1752..6b789988baa 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -2124,8 +2124,10 @@ ix86_option_override_internal (bool main_args_p, if (((processor_alias_table[i].flags & PTA_ABM) != 0) && !TARGET_EXPLICIT_ABM_P (opts)) { - SET_TARGET_LZCNT (opts); - SET_TARGET_POPCNT (opts); + if (!TARGET_EXPLICIT_LZCNT_P (opts)) + SET_TARGET_LZCNT (opts); + if (!TARGET_EXPLICIT_POPCNT_P (opts)) + SET_TARGET_POPCNT (opts); } if ((processor_alias_table[i].flags diff --git a/gcc/testsuite/gcc.target/i386/pr-101685.c b/gcc/testsuite/gcc.target/i386/pr-101685.c new file mode 100644 index 00000000000..0c743ecad00 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr-101685.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=amdfam10 -mno-lzcnt -mno-popcnt" } */ + +#ifdef __LZCNT__ +# error LZCNT should be disabled +#endif + +#ifdef __POPCNT__ +# error POPCNT should be disabled +#endif