From patchwork Wed Jul 10 08:44:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1958756 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=CnObnByh; 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 4WJryK60Pgz1xqc for ; Wed, 10 Jul 2024 18:44:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0BFAB3870871 for ; Wed, 10 Jul 2024 08:44:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 9E9B7386D60B for ; Wed, 10 Jul 2024 08:44:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E9B7386D60B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9E9B7386D60B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720601055; cv=none; b=j0QRt58809rzn/X59WPmUIQzRntSyuYfToPnI/El5giuvK51SeZbung0niUiFEpaM1hScEaKqAtWCRHsOQ/8xEPAO2wCBD41z4jhSYwzCXxR6uBlfYEK0O+0GHwChxumo+B0g4Zb9oIx0Yi/OeQ8AS2iUbu2rzwq3dPjoRdObsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720601055; c=relaxed/simple; bh=MqK7HfmpOnm/ONw6oRUaXpeTrSYBSZ8k50lkEvXNTBI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=AYd7ShAsTZsOiT4vnSCfwk6jaT8tbXSZMq52baDFy7xmLNf5okRBonUQr2oqpVPghDnNRO1hMW49Tq3vKTTH28WobeBvmv+b3uDnR/MlePTU3ix3XJCt5jPohyfoksWfCMzHGFEk8Xb2Z6FuZShZEvJLwzDoO/ef7Kh5oLLWIfs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46A8SHYt013562; Wed, 10 Jul 2024 08:44:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= message-id:date:mime-version:from:subject:to:cc:content-type :content-transfer-encoding; s=pp1; bh=Iw8JR5QyQnkpkGWvS+XkDTWpmY b+HYju2ch+vKucAFE=; b=CnObnByhrDh4LmNmpxH0EVofcmZ7NxB1VS24RZhNG5 2w1io3baPw5A5DvLkJFA2Ncls+rYB6zRHi+94mY117+Jc7O5RCxpkR3NWyTbmEZ9 IgIg4wqxfBow7gay15g3nl6C9pBtjVBWY+rH5w5jT3N+qRorwzd7HGTnWhnnBAsK nLF5b67HAhb53aiSoIa+9Jjiv6b5RdjQ8xD1ye5B0b/7Ra8PdUE1eiTx0AFPfSqN qKrkOdi6wQIjvK+3snrBmAMRhwO53hFBq1ICch4QCU4CVWkgT0SFrYFEhSIW0C21 aVlewthIAxP5T/SbATmIFDUDfyIAbjDooYGOuOZQuY7g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 409ptn019v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 08:44:12 +0000 (GMT) Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 46A8iBbA004063; Wed, 10 Jul 2024 08:44:11 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 409ptn019s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 08:44:11 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46A82eLM014029; Wed, 10 Jul 2024 08:44:10 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 407jy39ub4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 08:44:10 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46A8i5ee52494672 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jul 2024 08:44:07 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 834D720040; Wed, 10 Jul 2024 08:44:05 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E673F20043; Wed, 10 Jul 2024 08:44:03 +0000 (GMT) Received: from [9.200.158.244] (unknown [9.200.158.244]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 10 Jul 2024 08:44:03 +0000 (GMT) Message-ID: <1602c550-1189-dcd2-9053-ce080a2ac0a5@linux.ibm.com> Date: Wed, 10 Jul 2024 16:44:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US From: "Kewen.Lin" Subject: [PATCH] rs6000: Consider explicitly set options in target option parsing [PR115713] To: GCC Patches Cc: Segher Boessenkool , Peter Bergner , Michael Meissner , David Edelsohn X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9tTlT0hAHpNIWv3yFxExiUPCIFSMT1Pf X-Proofpoint-ORIG-GUID: d8wFbr2A7EsggpaeLrVWbgzfR_XSi-uy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-10_04,2024-07-09_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 phishscore=0 adultscore=0 clxscore=1015 bulkscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=926 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407100057 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, In rs6000_inner_target_options, when enabling VSX we enable altivec and disable -mavoid-indexed-addresses implicitly, but it doesn't consider the case that the options altivec and avoid-indexed-addresses can be explicitly disabled. As the test case in PR115713#c1 shows, with target attribute "no-altivec,vsx", it results in that VSX unexpectedly set altivec flag and there isn't an expected error. This patch is to avoid the automatic enablement when they are explicitly specified. With this change, an existing test case ppc-target-4.c also requires an adjustment by specifying explicit altivec in target attribute (since it requires altivec feature and command line is specifying no-altivec). Bootstrapped and regtested on powerpc64-linux-gnu P8/P9 and powerpc64le-linux-gnu P9 and P10. I'm going to push this next week if no objections. BR, Kewen ----- PR target/115713 gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_inner_target_options): Avoid to enable altivec or disable avoid-indexed-addresses automatically when they get specified explicitly. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr115713-1.c: New test. * gcc.target/powerpc/ppc-target-4.c: Adjust by specifying altivec in target attribute. --- gcc/config/rs6000/rs6000.cc | 7 +++++-- .../gcc.target/powerpc/ppc-target-4.c | 2 +- gcc/testsuite/gcc.target/powerpc/pr115713-1.c | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr115713-1.c -- 2.45.2 diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 3b1ee3a262a..ed7a9fdeb58 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -24643,8 +24643,11 @@ rs6000_inner_target_options (tree args, bool attr_p) { if (mask == OPTION_MASK_VSX) { - mask |= OPTION_MASK_ALTIVEC; - TARGET_AVOID_XFORM = 0; + if (!(rs6000_isa_flags_explicit + & OPTION_MASK_ALTIVEC)) + mask |= OPTION_MASK_ALTIVEC; + if (!OPTION_SET_P (TARGET_AVOID_XFORM)) + TARGET_AVOID_XFORM = 0; } } diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c b/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c index 43a98b353cf..db9ba500e0e 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c @@ -18,7 +18,7 @@ #error "__VSX__ should not be defined." #endif -#pragma GCC target("vsx") +#pragma GCC target("altivec,vsx") #include #pragma GCC reset_options diff --git a/gcc/testsuite/gcc.target/powerpc/pr115713-1.c b/gcc/testsuite/gcc.target/powerpc/pr115713-1.c new file mode 100644 index 00000000000..1b93a78682a --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr115713-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* Force power7 to avoid possible error message on AltiVec ABI change. */ +/* { dg-options "-mdejagnu-cpu=power7" } */ + +/* Verify there is an error message for incompatible -maltivec and -mvsx + even when they are specified by target attributes. */ + +int __attribute__ ((target ("no-altivec,vsx"))) +test1 (void) +{ + /* { dg-error "'-mvsx' and '-mno-altivec' are incompatible" "" { target *-*-* } .-1 } */ + return 0; +} + +int __attribute__ ((target ("vsx,no-altivec"))) +test2 (void) +{ + /* { dg-error "'-mvsx' and '-mno-altivec' are incompatible" "" { target *-*-* } .-1 } */ + return 0; +}