Message ID | bbeab8f4-490c-56c2-f155-4b4578221a4c@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 622D13858409 for <patchwork@sourceware.org>; Thu, 23 Dec 2021 02:13:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 622D13858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1640225581; bh=gtapfejqW4WDD1E9PIeThAlln/vlJOfRlIinN9rIcyE=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=p52CqCy/vs0ylbYnjujYKT8lMKLJ0vRKxFJstgyOYKAFZN47apr9N29Lh3JOH59BY hZ11807p4P6Y7A9OhA2rXRLdNB2WcEIOC7fiGJN9dsFwkr0VKVHM3WLvhH3ppghWVr gKnDXmdskzzN2ekWlke+ub32ii9LONsGi3kKBXaY= 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 E30C43858C60 for <gcc-patches@gcc.gnu.org>; Thu, 23 Dec 2021 02:12:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E30C43858C60 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BMMcutj040810; Thu, 23 Dec 2021 02:12:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d472s9u6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 02:12:30 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1BN20nEb039748; Thu, 23 Dec 2021 02:12:29 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d472s9u60-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 02:12:29 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BN2CGwA022285; Thu, 23 Dec 2021 02:12:27 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma02fra.de.ibm.com with ESMTP id 3d179a13fj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 02:12:27 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BN247Rc49873236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Dec 2021 02:04:08 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35986A405C; Thu, 23 Dec 2021 02:12:24 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82A2EA405B; Thu, 23 Dec 2021 02:12:22 +0000 (GMT) Received: from kewenlins-mbp.cn.ibm.com (unknown [9.200.147.85]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 23 Dec 2021 02:12:22 +0000 (GMT) Subject: [PATCH] rs6000: Move the hunk affecting VSX/ALTIVEC ahead [PR103627] To: GCC Patches <gcc-patches@gcc.gnu.org> Message-ID: <bbeab8f4-490c-56c2-f155-4b4578221a4c@linux.ibm.com> Date: Thu, 23 Dec 2021 10:12:19 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=gbk Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Hj2z3BOXj_KnyCoC7dfFUvwtaq3tKlST X-Proofpoint-GUID: yE1XMYNkYYDEgKkYKdh6WzsVGoZP3Bgx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-22_09,2021-12-22_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 adultscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112230008 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, 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 <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> From: "Kewen.Lin via Gcc-patches" <gcc-patches@gcc.gnu.org> Reply-To: "Kewen.Lin" <linkw@linux.ibm.com> Cc: Michael Meissner <meissner@linux.ibm.com>, Bill Schmidt <wschmidt@linux.ibm.com>, David Edelsohn <dje.gcc@gmail.com>, Segher Boessenkool <segher@kernel.crashing.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
rs6000: Move the hunk affecting VSX/ALTIVEC ahead [PR103627]
|
|
Commit Message
Kewen.Lin
Dec. 23, 2021, 2:12 a.m. UTC
Hi, There is one hunk checking for functions with target attribute/pragma have the same altivec abi as the one of main_target_opt, it can update both VSX and ALTIVEC flags. Meanwhile, we have some codes to check or warn for some isa flags related to VSX and ALTIVEC, that sit where the mentioned hunk is proposed to be moved to in this patch. Since the flags update in the mentioned hunk happen behind those adjustments based on VSX and ALTIVEC flags, it can cause the incompatibility and result in unexpected behaviors, the associated test case is one typical case. Besides, we already have the code which sets TARGET_FLOAT128_TYPE and lays after where the hunk is moved to, and OPTION_MASK_FLOAT128_KEYWORD will rely on TARGET_FLOAT128_TYPE, so this patch just simply removes them. Bootstrapped and regtested on powerpc64le-linux-gnu P9 and powerpc64-linux-gnu P8 and P7. Is it ok for trunk? BR, Kewen ----- gcc/ChangeLog: PR target/103627 * config/rs6000/rs6000.c (rs6000_option_override_internal): Move the hunk affecting VSX and ALTIVEC to the appropriate place. gcc/testsuite/ChangeLog: PR target/103627 * gcc.target/powerpc/pr103627-3.c: New test. --- gcc/config/rs6000/rs6000.c | 21 ++++++++----------- gcc/testsuite/gcc.target/powerpc/pr103627-3.c | 20 ++++++++++++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr103627-3.c -- 2.27.0
Comments
Gentle ping: https://gcc.gnu.org/pipermail/gcc-patches/2021-December/587311.html on 2021/12/23 上午10:12, Kewen.Lin via Gcc-patches wrote: > Hi, > > There is one hunk checking for functions with target attribute/pragma > have the same altivec abi as the one of main_target_opt, it can update > both VSX and ALTIVEC flags. Meanwhile, we have some codes to check or > warn for some isa flags related to VSX and ALTIVEC, that sit where the > mentioned hunk is proposed to be moved to in this patch. > > Since the flags update in the mentioned hunk happen behind those > adjustments based on VSX and ALTIVEC flags, it can cause the > incompatibility and result in unexpected behaviors, the associated test > case is one typical case. > > Besides, we already have the code which sets TARGET_FLOAT128_TYPE and > lays after where the hunk is moved to, and OPTION_MASK_FLOAT128_KEYWORD > will rely on TARGET_FLOAT128_TYPE, so this patch just simply removes them. > > Bootstrapped and regtested on powerpc64le-linux-gnu P9 and > powerpc64-linux-gnu P8 and P7. > > Is it ok for trunk? > > BR, > Kewen > ----- > gcc/ChangeLog: > > PR target/103627 > * config/rs6000/rs6000.c (rs6000_option_override_internal): Move the > hunk affecting VSX and ALTIVEC to the appropriate place. > > gcc/testsuite/ChangeLog: > > PR target/103627 > * gcc.target/powerpc/pr103627-3.c: New test. > --- > gcc/config/rs6000/rs6000.c | 21 ++++++++----------- > gcc/testsuite/gcc.target/powerpc/pr103627-3.c | 20 ++++++++++++++++++ > 2 files changed, 29 insertions(+), 12 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr103627-3.c > > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > index ec3b46682a7..0b09713b2f5 100644 > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > @@ -3955,6 +3955,15 @@ rs6000_option_override_internal (bool global_init_p) > else if (TARGET_ALTIVEC) > rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~ignore_masks); > > + /* Disable VSX and Altivec silently if the user switched cpus to power7 in a > + target attribute or pragma which automatically enables both options, > + unless the altivec ABI was set. This is set by default for 64-bit, but > + 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 != NULL && !main_target_opt->x_rs6000_altivec_abi) > + rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) > + & ~rs6000_isa_flags_explicit); > + > if (TARGET_CRYPTO && !TARGET_ALTIVEC) > { > if (rs6000_isa_flags_explicit & OPTION_MASK_CRYPTO) > @@ -4373,18 +4382,6 @@ rs6000_option_override_internal (bool global_init_p) > } > } > > - /* Disable VSX and Altivec silently if the user switched cpus to power7 in a > - target attribute or pragma which automatically enables both options, > - unless the altivec ABI was set. This is set by default for 64-bit, but > - not for 32-bit. */ > - if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi) > - { > - TARGET_FLOAT128_TYPE = 0; > - rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC > - | OPTION_MASK_FLOAT128_KEYWORD) > - & ~rs6000_isa_flags_explicit); > - } > - > /* Enable Altivec ABI for AIX -maltivec. */ > if (TARGET_XCOFF > && (TARGET_ALTIVEC || TARGET_VSX) > diff --git a/gcc/testsuite/gcc.target/powerpc/pr103627-3.c b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c > new file mode 100644 > index 00000000000..9df2b73fe85 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c > @@ -0,0 +1,20 @@ > +/* There are no error messages for either LE or BE 64bit. */ > +/* { dg-require-effective-target be }*/ > +/* { dg-require-effective-target ilp32 } */ > +/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */ > +/* { dg-require-effective-target powerpc_altivec_ok } */ > +/* { dg-options "-mdejagnu-cpu=power6" } */ > + > +/* Verify compiler emits error message instead of ICE. */ > + > +#pragma GCC target "cpu=power10" > +int > +main () > +{ > + float *b; > + __vector_quad c; > + __builtin_mma_disassemble_acc (b, &c); > + /* { dg-error "'__builtin_mma_disassemble_acc' requires the '-mmma' option" "" { target *-*-* } .-1 } */ > + return 0; > +} > + > -- > 2.27.0 >
Gentle ping: https://gcc.gnu.org/pipermail/gcc-patches/2021-December/587311.html BR, Kewen > on 2021/12/23 上午10:12, Kewen.Lin via Gcc-patches wrote: >> Hi, >> >> There is one hunk checking for functions with target attribute/pragma >> have the same altivec abi as the one of main_target_opt, it can update >> both VSX and ALTIVEC flags. Meanwhile, we have some codes to check or >> warn for some isa flags related to VSX and ALTIVEC, that sit where the >> mentioned hunk is proposed to be moved to in this patch. >> >> Since the flags update in the mentioned hunk happen behind those >> adjustments based on VSX and ALTIVEC flags, it can cause the >> incompatibility and result in unexpected behaviors, the associated test >> case is one typical case. >> >> Besides, we already have the code which sets TARGET_FLOAT128_TYPE and >> lays after where the hunk is moved to, and OPTION_MASK_FLOAT128_KEYWORD >> will rely on TARGET_FLOAT128_TYPE, so this patch just simply removes them. >> >> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and >> powerpc64-linux-gnu P8 and P7. >> >> Is it ok for trunk? >> >> BR, >> Kewen >> ----- >> gcc/ChangeLog: >> >> PR target/103627 >> * config/rs6000/rs6000.c (rs6000_option_override_internal): Move the >> hunk affecting VSX and ALTIVEC to the appropriate place. >> >> gcc/testsuite/ChangeLog: >> >> PR target/103627 >> * gcc.target/powerpc/pr103627-3.c: New test. >> --- >> gcc/config/rs6000/rs6000.c | 21 ++++++++----------- >> gcc/testsuite/gcc.target/powerpc/pr103627-3.c | 20 ++++++++++++++++++ >> 2 files changed, 29 insertions(+), 12 deletions(-) >> create mode 100644 gcc/testsuite/gcc.target/powerpc/pr103627-3.c >> >> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c >> index ec3b46682a7..0b09713b2f5 100644 >> --- a/gcc/config/rs6000/rs6000.c >> +++ b/gcc/config/rs6000/rs6000.c >> @@ -3955,6 +3955,15 @@ rs6000_option_override_internal (bool global_init_p) >> else if (TARGET_ALTIVEC) >> rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~ignore_masks); >> >> + /* Disable VSX and Altivec silently if the user switched cpus to power7 in a >> + target attribute or pragma which automatically enables both options, >> + unless the altivec ABI was set. This is set by default for 64-bit, but >> + 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 != NULL && !main_target_opt->x_rs6000_altivec_abi) >> + rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) >> + & ~rs6000_isa_flags_explicit); >> + >> if (TARGET_CRYPTO && !TARGET_ALTIVEC) >> { >> if (rs6000_isa_flags_explicit & OPTION_MASK_CRYPTO) >> @@ -4373,18 +4382,6 @@ rs6000_option_override_internal (bool global_init_p) >> } >> } >> >> - /* Disable VSX and Altivec silently if the user switched cpus to power7 in a >> - target attribute or pragma which automatically enables both options, >> - unless the altivec ABI was set. This is set by default for 64-bit, but >> - not for 32-bit. */ >> - if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi) >> - { >> - TARGET_FLOAT128_TYPE = 0; >> - rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC >> - | OPTION_MASK_FLOAT128_KEYWORD) >> - & ~rs6000_isa_flags_explicit); >> - } >> - >> /* Enable Altivec ABI for AIX -maltivec. */ >> if (TARGET_XCOFF >> && (TARGET_ALTIVEC || TARGET_VSX) >> diff --git a/gcc/testsuite/gcc.target/powerpc/pr103627-3.c b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c >> new file mode 100644 >> index 00000000000..9df2b73fe85 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c >> @@ -0,0 +1,20 @@ >> +/* There are no error messages for either LE or BE 64bit. */ >> +/* { dg-require-effective-target be }*/ >> +/* { dg-require-effective-target ilp32 } */ >> +/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */ >> +/* { dg-require-effective-target powerpc_altivec_ok } */ >> +/* { dg-options "-mdejagnu-cpu=power6" } */ >> + >> +/* Verify compiler emits error message instead of ICE. */ >> + >> +#pragma GCC target "cpu=power10" >> +int >> +main () >> +{ >> + float *b; >> + __vector_quad c; >> + __builtin_mma_disassemble_acc (b, &c); >> + /* { dg-error "'__builtin_mma_disassemble_acc' requires the '-mmma' option" "" { target *-*-* } .-1 } */ >> + return 0; >> +} >> + >> -- >> 2.27.0 >>
Hi! On Thu, Dec 23, 2021 at 10:12:19AM +0800, Kewen.Lin wrote: > PR target/103627 > * config/rs6000/rs6000.c (rs6000_option_override_internal): Move the > hunk affecting VSX and ALTIVEC to the appropriate place. > > gcc/testsuite/ChangeLog: > > PR target/103627 > * gcc.target/powerpc/pr103627-3.c: New test. > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > @@ -3955,6 +3955,15 @@ rs6000_option_override_internal (bool global_init_p) > else if (TARGET_ALTIVEC) > rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~ignore_masks); > > + /* Disable VSX and Altivec silently if the user switched cpus to power7 in a > + target attribute or pragma which automatically enables both options, > + unless the altivec ABI was set. This is set by default for 64-bit, but > + 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 != NULL && !main_target_opt->x_rs6000_altivec_abi) > + rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) > + & ~rs6000_isa_flags_explicit); Could you at the same time get rid of the != NULL please? if (bla != NULL) is sillier than if (bla != 0) which is about the same as if (!!bla) but that is certainly better than if (bla != 0 != 0) although I am not sure about the more stylish if (bla != 0 != 0 != 0 != 0 != 0) but what is wrong with if (bla) ? :-) > +/* There are no error messages for either LE or BE 64bit. */ > +/* { dg-require-effective-target be }*/ (space before */) > +/* { dg-require-effective-target ilp32 } */ > +/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */ > +/* { dg-require-effective-target powerpc_altivec_ok } */ > +/* { dg-options "-mdejagnu-cpu=power6" } */ It is okay always, no _ok at all please. Okay for trunk with those things (but do test of course). Thanks! Segher
Hi Segher, on 2022/1/27 上午6:42, Segher Boessenkool wrote: > Hi! > > On Thu, Dec 23, 2021 at 10:12:19AM +0800, Kewen.Lin wrote: >> PR target/103627 >> * config/rs6000/rs6000.c (rs6000_option_override_internal): Move the >> hunk affecting VSX and ALTIVEC to the appropriate place. >> >> gcc/testsuite/ChangeLog: >> >> PR target/103627 >> * gcc.target/powerpc/pr103627-3.c: New test. > > >> --- a/gcc/config/rs6000/rs6000.c >> +++ b/gcc/config/rs6000/rs6000.c >> @@ -3955,6 +3955,15 @@ rs6000_option_override_internal (bool global_init_p) >> else if (TARGET_ALTIVEC) >> rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~ignore_masks); >> >> + /* Disable VSX and Altivec silently if the user switched cpus to power7 in a >> + target attribute or pragma which automatically enables both options, >> + unless the altivec ABI was set. This is set by default for 64-bit, but >> + 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 != NULL && !main_target_opt->x_rs6000_altivec_abi) >> + rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) >> + & ~rs6000_isa_flags_explicit); > > Could you at the same time get rid of the != NULL please? > if (bla != NULL) > is sillier than > if (bla != 0) > which is about the same as > if (!!bla) > but that is certainly better than > if (bla != 0 != 0) > although I am not sure about the more stylish > if (bla != 0 != 0 != 0 != 0 != 0) > but what is wrong with > if (bla) > ? :-) > >> +/* There are no error messages for either LE or BE 64bit. */ >> +/* { dg-require-effective-target be }*/ > > (space before */) > >> +/* { dg-require-effective-target ilp32 } */ >> +/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */ >> +/* { dg-require-effective-target powerpc_altivec_ok } */ >> +/* { dg-options "-mdejagnu-cpu=power6" } */ > > It is okay always, no _ok at all please. > > Okay for trunk with those things (but do test of course). Thanks! > > Thanks for the review comments! I've addressed them in the attached patch. Besides, I updated the case a bit by adding -mno-avoid-indexed-addresses, otherwise the associated case would have one unexpected warning which is supposed to be fixed by [1]. But even with this adjustment, this patch still relies on [2], otherwise the associated case will get ICE instead. btw, it can survives in all the testings as before together with [2]. So I'll hold this to commit until [2] gets landed. [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-December/587449.html [2] https://gcc.gnu.org/pipermail/gcc-patches/2022-January/589325.html BR, Kewen From 90565d869395df08a65d521ddad8684a99e844a5 Mon Sep 17 00:00:00 2001 From: Kewen Lin <linkw@linux.ibm.com> Date: Thu, 27 Jan 2022 00:25:29 -0600 Subject: [PATCH 3/3] rs6000: Move the hunk affecting VSX/ALTIVEC ahead [PR103627] The modified hunk can update VSX and ALTIVEC flag, we have some codes to check/warn for some flags related to VSX and ALTIVEC sitting where the hunk is proprosed to be moved to. Without this adjustment, the VSX and ALTIVEC update is too late, it can cause the incompatibility and result in unexpected behaviors, the associated test case is one typical case. Since we already have the code which sets TARGET_FLOAT128_TYPE and lays after the moved place, and OPTION_MASK_FLOAT128_KEYWORD will rely on TARGET_FLOAT128_TYPE, so it just simply remove them. gcc/ChangeLog: PR target/103627 * config/rs6000/rs6000.cc (rs6000_option_override_internal): Move the hunk affecting VSX and ALTIVEC to appropriate place. gcc/testsuite/ChangeLog: PR target/103627 * gcc.target/powerpc/pr103627-3.c: New test. --- gcc/config/rs6000/rs6000.cc | 21 ++++++++----------- gcc/testsuite/gcc.target/powerpc/pr103627-3.c | 20 ++++++++++++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr103627-3.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 634937e052f..f90fd8955cd 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -3943,6 +3943,15 @@ rs6000_option_override_internal (bool global_init_p) else if (TARGET_ALTIVEC) rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~ignore_masks); + /* Disable VSX and Altivec silently if the user switched cpus to power7 in a + target attribute or pragma which automatically enables both options, + unless the altivec ABI was set. This is set by default for 64-bit, but + 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); + if (TARGET_CRYPTO && !TARGET_ALTIVEC) { if (rs6000_isa_flags_explicit & OPTION_MASK_CRYPTO) @@ -4359,18 +4368,6 @@ rs6000_option_override_internal (bool global_init_p) } } - /* Disable VSX and Altivec silently if the user switched cpus to power7 in a - target attribute or pragma which automatically enables both options, - unless the altivec ABI was set. This is set by default for 64-bit, but - not for 32-bit. */ - if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi) - { - TARGET_FLOAT128_TYPE = 0; - rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC - | OPTION_MASK_FLOAT128_KEYWORD) - & ~rs6000_isa_flags_explicit); - } - /* Enable Altivec ABI for AIX -maltivec. */ if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX) diff --git a/gcc/testsuite/gcc.target/powerpc/pr103627-3.c b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c new file mode 100644 index 00000000000..5a4d5ba5701 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c @@ -0,0 +1,20 @@ +/* There are no error messages for either LE or BE 64bit. */ +/* { dg-require-effective-target be } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-mdejagnu-cpu=power6" } */ + +/* Verify compiler emits error message instead of ICE. */ + +/* Option -mno-avoid-indexed-addresses is to disable the unexpected + warning on indexed addressing which can affect dg checks. */ +#pragma GCC target "cpu=power10,no-avoid-indexed-addresses" +int +main () +{ + float *b; + __vector_quad c; + __builtin_mma_disassemble_acc (b, &c); + /* { dg-error "'__builtin_mma_disassemble_acc' requires the '-mmma' option" "" { target *-*-* } .-1 } */ + return 0; +} +
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index ec3b46682a7..0b09713b2f5 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3955,6 +3955,15 @@ rs6000_option_override_internal (bool global_init_p) else if (TARGET_ALTIVEC) rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~ignore_masks); + /* Disable VSX and Altivec silently if the user switched cpus to power7 in a + target attribute or pragma which automatically enables both options, + unless the altivec ABI was set. This is set by default for 64-bit, but + 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 != NULL && !main_target_opt->x_rs6000_altivec_abi) + rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC) + & ~rs6000_isa_flags_explicit); + if (TARGET_CRYPTO && !TARGET_ALTIVEC) { if (rs6000_isa_flags_explicit & OPTION_MASK_CRYPTO) @@ -4373,18 +4382,6 @@ rs6000_option_override_internal (bool global_init_p) } } - /* Disable VSX and Altivec silently if the user switched cpus to power7 in a - target attribute or pragma which automatically enables both options, - unless the altivec ABI was set. This is set by default for 64-bit, but - not for 32-bit. */ - if (main_target_opt != NULL && !main_target_opt->x_rs6000_altivec_abi) - { - TARGET_FLOAT128_TYPE = 0; - rs6000_isa_flags &= ~((OPTION_MASK_VSX | OPTION_MASK_ALTIVEC - | OPTION_MASK_FLOAT128_KEYWORD) - & ~rs6000_isa_flags_explicit); - } - /* Enable Altivec ABI for AIX -maltivec. */ if (TARGET_XCOFF && (TARGET_ALTIVEC || TARGET_VSX) diff --git a/gcc/testsuite/gcc.target/powerpc/pr103627-3.c b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c new file mode 100644 index 00000000000..9df2b73fe85 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr103627-3.c @@ -0,0 +1,20 @@ +/* There are no error messages for either LE or BE 64bit. */ +/* { dg-require-effective-target be }*/ +/* { dg-require-effective-target ilp32 } */ +/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-mdejagnu-cpu=power6" } */ + +/* Verify compiler emits error message instead of ICE. */ + +#pragma GCC target "cpu=power10" +int +main () +{ + float *b; + __vector_quad c; + __builtin_mma_disassemble_acc (b, &c); + /* { dg-error "'__builtin_mma_disassemble_acc' requires the '-mmma' option" "" { target *-*-* } .-1 } */ + return 0; +} +