From patchwork Fri Jul 5 03:18:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1957099 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=nSrboPIW; 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 4WFdyM53pXz1xqw for ; Fri, 5 Jul 2024 13:18:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8ABE8384A05C for ; Fri, 5 Jul 2024 03:18:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 6ADF6384A054 for ; Fri, 5 Jul 2024 03:18:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6ADF6384A054 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 6ADF6384A054 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720149494; cv=none; b=RJMv+njhjFaEZikFlE7scSK48nZdLgUAzUGV+Je4Of1Tw/Rav8YbhylhfmPxORyOgyvMEVhnKaDuIR0830fwPXh11yVJyUiD3MhjmAUC7Am72S3afVDx38S070lqt3Iy4x01G0TqlXFjnG9bdApPEfOGOXpCwD1f17SKOeftDJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720149494; c=relaxed/simple; bh=duneTvYSQU766CIy457L3SCGZpUrNz1LFqX6+TkKHIA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=TtNq67jcTErqXTp3F7GOR6orlny4lb4X9OMLFmhczlE24Ja4dp2SgDMXWRGElQitwDUrw29hnMeI5IGKx8976KFSYRSBylsWPH6RtQewCyYl1FON/EQyAsDgGkU2CkmliGY/JShc/sshXgXpri5qWkkZELK+jSSSCgnVck6yn3w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4653DOsK022101; Fri, 5 Jul 2024 03:18: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=MzNMH7h9mGMEjHvR+V2Viobhk6 QxFNIuXJF5QHh+NbA=; b=nSrboPIWRnk7IIjjqYfrS+SxUbisRCusdqpznvu7tD zz4K6mW1ze7bSxIVwkSkXSelD3edXs5ZwcYi6HTJoxebzP56xT3ULuP36vZjOkB/ 9DJm95Vt3a12FbevVRXTtw/0PcRFpR98HC3J/oUrWEVMw6Vje+2N1c9pqNpkngZT s2cY1Pghk2OkoVmJnC3gdEZJpYXCCEFLRUPURgQk3hW2IMUj9XnCWfwzheWsy/mv Wrj1F03JR02lfyA/lkXoJ/U914We+hImhApSQEN0NchsHdjIiJ4hpMywuzLkUx9h SmCbD+zW/2efbNMTlXem20NB6MSOzCm5Ycco1M6wRjyg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40676t05m1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jul 2024 03:18:12 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4653ICe5030508; Fri, 5 Jul 2024 03:18:12 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40676t05ky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jul 2024 03:18:11 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46525mYB005961; Fri, 5 Jul 2024 03:18:11 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 402vkukne3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jul 2024 03:18:11 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4653I7Z350856346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jul 2024 03:18:09 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FAD920040; Fri, 5 Jul 2024 03:18:07 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0671C20043; Fri, 5 Jul 2024 03:18:06 +0000 (GMT) Received: from [9.200.52.232] (unknown [9.200.52.232]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jul 2024 03:18:05 +0000 (GMT) Message-ID: <80e7cdfc-6066-91d8-ec1e-da2dc0016be6@linux.ibm.com> Date: Fri, 5 Jul 2024 11:18:04 +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 explicit VSX when masking off ALTIVEC [PR115688] To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , Peter Bergner X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ismO0H0KAOjYc94Iwl0N024aHPoF0N_R X-Proofpoint-GUID: NaXDTJKj-eKvxwJjrUM4Pcezr4E0CSLA 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-04_21,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 adultscore=0 mlxlogscore=822 mlxscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407050020 X-Spam-Status: No, score=-12.4 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, PR115688 exposes an inconsistent state in which we have VSX enabled but ALTIVEC disabled. There is one hunk: if (main_target_opt && !main_target_opt->x_rs6000_altivec_abi) rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) & ~rs6000_isa_flags_explicit); which disables both VSX and ALTIVEC together only considering them explicitly set or not. For the given case, VSX is explicitly specified, altivec is implicitly enabled as it's part of set ISA_2_6_MASKS_SERVER. When falling into the above hunk, vsx is kept as it's explicitly enabled but altivec gets masked off, it's unexpected. This patch is to consider explicit VSX when masking off ALTIVEC, not mask off it if TARGET_VSX and it's explicitly set. 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/115688 gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_option_override_internal): Consider explicit VSX when masking off ALTIVEC. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr115688.c: New test. --- gcc/config/rs6000/rs6000.cc | 8 ++++++-- gcc/testsuite/gcc.target/powerpc/pr115688.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr115688.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 58553ff66f4..2cbea6ea2d7 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -3933,8 +3933,12 @@ rs6000_option_override_internal (bool global_init_p) not for 32-bit. Don't move this before the above code using ignore_masks, since it can reset the cleared VSX/ALTIVEC flag again. */ if (main_target_opt && !main_target_opt->x_rs6000_altivec_abi) - rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) - & ~rs6000_isa_flags_explicit); + { + rs6000_isa_flags &= ~(OPTION_MASK_VSX & ~rs6000_isa_flags_explicit); + /* Don't mask off ALTIVEC if it is enabled by an explicit VSX. */ + if (!TARGET_VSX) + rs6000_isa_flags &= ~(OPTION_MASK_ALTIVEC & ~rs6000_isa_flags_explicit); + } if (TARGET_CRYPTO && !TARGET_ALTIVEC) { diff --git a/gcc/testsuite/gcc.target/powerpc/pr115688.c b/gcc/testsuite/gcc.target/powerpc/pr115688.c new file mode 100644 index 00000000000..5222e66ef17 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr115688.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target powerpc*-*-linux* } } */ +/* { dg-options "-mdejagnu-cpu=power5 -O2" } */ + +/* Ignore some error messages on "target attribute or + pragma changes AltiVec ABI". */ +/* { dg-excess-errors "pr115688" { target ilp32 } } */ + +/* Verify there is no ICE under 32 bit env. */ + +__attribute__((target("vsx"))) +int test (void) +{ + return 0; +}