Message ID | 20230531043249.2561061-1-apinski@marvell.com |
---|---|
State | Committed |
Commit | df0853d72d38247aed577a4511450c91794f2f06 |
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 E5FC83857028 for <patchwork@sourceware.org>; Wed, 31 May 2023 04:34:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5FC83857028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685507659; bh=fD6dvP0CcINKJ95PqwoEv0sEjxZGuehq/sfMFP2g0+U=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=A2qGZLr/xoDiV9VFYFXrneEHB3K4PjT5D0RXtBUcTpmmkVpsi8dgp8IePhiFr+123 BG7Tm5kx2G7DwTdzQwHSmDGhQDAAGrXCJIZ12LYFEtoWiA8cVrYd82kZZd6ZVJ4HMd KsNqe6/au6RF102yvKOC4OaodhRtsdvHYM2UI+P8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 4B0253858C5E for <gcc-patches@gcc.gnu.org>; Wed, 31 May 2023 04:33:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B0253858C5E Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34ULjZpm019356 for <gcc-patches@gcc.gnu.org>; Tue, 30 May 2023 21:33:47 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qwsb8scv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Tue, 30 May 2023 21:33:47 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 30 May 2023 21:33:45 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 30 May 2023 21:33:45 -0700 Received: from vpnclient.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 8A7443F7063; Tue, 30 May 2023 21:33:44 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> CC: Andrew Pinski <apinski@marvell.com> Subject: [PATCH] Fix PR 110042: ifcvt regression due to paradoxical subregs Date: Tue, 30 May 2023 21:32:49 -0700 Message-ID: <20230531043249.2561061-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: N_0tbG52frinj9AiXPey_4gb4TVDZJn_ X-Proofpoint-GUID: N_0tbG52frinj9AiXPey_4gb4TVDZJn_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-30_18,2023-05-30_01,2023-05-22_02 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.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: Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Andrew Pinski <apinski@marvell.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
Fix PR 110042: ifcvt regression due to paradoxical subregs
|
|
Commit Message
Andrew Pinski
May 31, 2023, 4:32 a.m. UTC
After r14-1014-gc5df248509b489364c573e8, GCC started to emit directly a zero_extract for `(t1&0x8)!=0`. This introduced a small regression where ifcvt would not do the ifconversion as there is now a paradoxical subreg in the dest which was being rejected. Since paradoxical subreg set the whole register, we can treat it as the same as a reg in the two places. OK? Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu. gcc/ChangeLog: PR rtl-optimization/110042 * ifcvt.cc (bbs_ok_for_cmove_arith): Allow paradoxical subregs. (bb_valid_for_noce_process_p): Strip the subreg for the SET_DEST. gcc/testsuite/ChangeLog: PR rtl-optimization/110042 * gcc.target/aarch64/csel_bfx_2.c: New test. --- gcc/ifcvt.cc | 14 ++++++---- gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c | 27 +++++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c
Comments
On Wed, May 31, 2023 at 6:34 AM Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > After r14-1014-gc5df248509b489364c573e8, GCC started to emit > directly a zero_extract for `(t1&0x8)!=0`. This introduced > a small regression where ifcvt would not do the ifconversion > as there is now a paradoxical subreg in the dest which > was being rejected. Since paradoxical subreg set the whole > register, we can treat it as the same as a reg in the two places. > > OK? Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu. OK I guess. I vaguely remember SUBREG_PROMOTED_UNSIGNED_P applies to non-paradoxical subregs but I might be swapping things - maybe you remember better and whether that would cause any issues here? Thanks, Richard. > gcc/ChangeLog: > > PR rtl-optimization/110042 > * ifcvt.cc (bbs_ok_for_cmove_arith): Allow paradoxical subregs. > (bb_valid_for_noce_process_p): Strip the subreg for the SET_DEST. > > gcc/testsuite/ChangeLog: > > PR rtl-optimization/110042 > * gcc.target/aarch64/csel_bfx_2.c: New test. > --- > gcc/ifcvt.cc | 14 ++++++---- > gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c | 27 +++++++++++++++++++ > 2 files changed, 36 insertions(+), 5 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c > > diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc > index 868eda93251..0b180b4568f 100644 > --- a/gcc/ifcvt.cc > +++ b/gcc/ifcvt.cc > @@ -2022,7 +2022,7 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block bb_b, rtx to_rename) > } > > /* Make sure this is a REG and not some instance > - of ZERO_EXTRACT or SUBREG or other dangerous stuff. > + of ZERO_EXTRACT or non-paradoxical SUBREG or other dangerous stuff. > If we have a memory destination then we have a pair of simple > basic blocks performing an operation of the form [addr] = c ? a : b. > bb_valid_for_noce_process_p will have ensured that these are > @@ -2030,7 +2030,8 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block bb_b, rtx to_rename) > to be renamed. Assert that the callers set this up properly. */ > if (MEM_P (SET_DEST (sset_b))) > gcc_assert (rtx_equal_p (SET_DEST (sset_b), to_rename)); > - else if (!REG_P (SET_DEST (sset_b))) > + else if (!REG_P (SET_DEST (sset_b)) > + && !paradoxical_subreg_p (SET_DEST (sset_b))) > { > BITMAP_FREE (bba_sets); > return false; > @@ -3136,14 +3137,17 @@ bb_valid_for_noce_process_p (basic_block test_bb, rtx cond, > > rtx sset = single_set (insn); > gcc_assert (sset); > + rtx dest = SET_DEST (sset); > + if (SUBREG_P (dest)) > + dest = SUBREG_REG (dest); > > if (contains_mem_rtx_p (SET_SRC (sset)) > - || !REG_P (SET_DEST (sset)) > - || reg_overlap_mentioned_p (SET_DEST (sset), cond)) > + || !REG_P (dest) > + || reg_overlap_mentioned_p (dest, cond)) > goto free_bitmap_and_fail; > > potential_cost += pattern_cost (sset, speed_p); > - bitmap_set_bit (test_bb_temps, REGNO (SET_DEST (sset))); > + bitmap_set_bit (test_bb_temps, REGNO (dest)); > } > } > > diff --git a/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c b/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c > new file mode 100644 > index 00000000000..c3b8a6f45cc > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c > @@ -0,0 +1,27 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > +unsigned > +f1(int t, int t1) > +{ > + int tt = 0; > + if(t) > + tt = (t1&0x8)!=0; > + return tt; > +} > +struct f > +{ > + unsigned t:3; > + unsigned t1:4; > +}; > +unsigned > +f2(int t, struct f y) > +{ > + int tt = 0; > + if(t) > + tt = y.t1; > + return tt; > +} > +/* Both f1 and f2 should produce a csel and not a cbz on the argument. */ > +/* { dg-final { scan-assembler-times "csel\t" 2 } } */ > +/* { dg-final { scan-assembler-times "ubfx\t" 2 } } */ > +/* { dg-final { scan-assembler-not "cbz\t" } } */ > -- > 2.31.1 >
On Wed, May 31, 2023 at 12:29 AM Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Wed, May 31, 2023 at 6:34 AM Andrew Pinski via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > After r14-1014-gc5df248509b489364c573e8, GCC started to emit > > directly a zero_extract for `(t1&0x8)!=0`. This introduced > > a small regression where ifcvt would not do the ifconversion > > as there is now a paradoxical subreg in the dest which > > was being rejected. Since paradoxical subreg set the whole > > register, we can treat it as the same as a reg in the two places. > > > > OK? Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu. > > OK I guess. I vaguely remember SUBREG_PROMOTED_UNSIGNED_P > applies to non-paradoxical subregs but I might be swapping things - maybe > you remember better and whether that would cause any issues here? So I looked into the history of the code in ifcvt.cc, this code was added with r6-3071-ge65bf4e814d38c to accept more complex bb (https://inbox.sourceware.org/gcc-patches/559FBB13.80009@arm.com/). The thread where we start talking about subregs is located with Jeff's email starting here: https://inbox.sourceware.org/gcc-patches/55BBAFAC.5020608@redhat.com/ . Jeff, I know Richard already approved this patch but could you provide a second eye as you were involved reviewing the original code here and I want to make sure I understood the code in a a reasonable fashion? Thanks, Andrew > > Thanks, > Richard. > > > gcc/ChangeLog: > > > > PR rtl-optimization/110042 > > * ifcvt.cc (bbs_ok_for_cmove_arith): Allow paradoxical subregs. > > (bb_valid_for_noce_process_p): Strip the subreg for the SET_DEST. > > > > gcc/testsuite/ChangeLog: > > > > PR rtl-optimization/110042 > > * gcc.target/aarch64/csel_bfx_2.c: New test. > > --- > > gcc/ifcvt.cc | 14 ++++++---- > > gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c | 27 +++++++++++++++++++ > > 2 files changed, 36 insertions(+), 5 deletions(-) > > create mode 100644 gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c > > > > diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc > > index 868eda93251..0b180b4568f 100644 > > --- a/gcc/ifcvt.cc > > +++ b/gcc/ifcvt.cc > > @@ -2022,7 +2022,7 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block bb_b, rtx to_rename) > > } > > > > /* Make sure this is a REG and not some instance > > - of ZERO_EXTRACT or SUBREG or other dangerous stuff. > > + of ZERO_EXTRACT or non-paradoxical SUBREG or other dangerous stuff. > > If we have a memory destination then we have a pair of simple > > basic blocks performing an operation of the form [addr] = c ? a : b. > > bb_valid_for_noce_process_p will have ensured that these are > > @@ -2030,7 +2030,8 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block bb_b, rtx to_rename) > > to be renamed. Assert that the callers set this up properly. */ > > if (MEM_P (SET_DEST (sset_b))) > > gcc_assert (rtx_equal_p (SET_DEST (sset_b), to_rename)); > > - else if (!REG_P (SET_DEST (sset_b))) > > + else if (!REG_P (SET_DEST (sset_b)) > > + && !paradoxical_subreg_p (SET_DEST (sset_b))) > > { > > BITMAP_FREE (bba_sets); > > return false; > > @@ -3136,14 +3137,17 @@ bb_valid_for_noce_process_p (basic_block test_bb, rtx cond, > > > > rtx sset = single_set (insn); > > gcc_assert (sset); > > + rtx dest = SET_DEST (sset); > > + if (SUBREG_P (dest)) > > + dest = SUBREG_REG (dest); > > > > if (contains_mem_rtx_p (SET_SRC (sset)) > > - || !REG_P (SET_DEST (sset)) > > - || reg_overlap_mentioned_p (SET_DEST (sset), cond)) > > + || !REG_P (dest) > > + || reg_overlap_mentioned_p (dest, cond)) > > goto free_bitmap_and_fail; > > > > potential_cost += pattern_cost (sset, speed_p); > > - bitmap_set_bit (test_bb_temps, REGNO (SET_DEST (sset))); > > + bitmap_set_bit (test_bb_temps, REGNO (dest)); > > } > > } > > > > diff --git a/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c b/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c > > new file mode 100644 > > index 00000000000..c3b8a6f45cc > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c > > @@ -0,0 +1,27 @@ > > +/* { dg-do compile } */ > > +/* { dg-options "-O2" } */ > > +unsigned > > +f1(int t, int t1) > > +{ > > + int tt = 0; > > + if(t) > > + tt = (t1&0x8)!=0; > > + return tt; > > +} > > +struct f > > +{ > > + unsigned t:3; > > + unsigned t1:4; > > +}; > > +unsigned > > +f2(int t, struct f y) > > +{ > > + int tt = 0; > > + if(t) > > + tt = y.t1; > > + return tt; > > +} > > +/* Both f1 and f2 should produce a csel and not a cbz on the argument. */ > > +/* { dg-final { scan-assembler-times "csel\t" 2 } } */ > > +/* { dg-final { scan-assembler-times "ubfx\t" 2 } } */ > > +/* { dg-final { scan-assembler-not "cbz\t" } } */ > > -- > > 2.31.1 > >
On 5/31/23 15:22, Andrew Pinski wrote: > On Wed, May 31, 2023 at 12:29 AM Richard Biener via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> >> On Wed, May 31, 2023 at 6:34 AM Andrew Pinski via Gcc-patches >> <gcc-patches@gcc.gnu.org> wrote: >>> >>> After r14-1014-gc5df248509b489364c573e8, GCC started to emit >>> directly a zero_extract for `(t1&0x8)!=0`. This introduced >>> a small regression where ifcvt would not do the ifconversion >>> as there is now a paradoxical subreg in the dest which >>> was being rejected. Since paradoxical subreg set the whole >>> register, we can treat it as the same as a reg in the two places. >>> >>> OK? Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu. >> >> OK I guess. I vaguely remember SUBREG_PROMOTED_UNSIGNED_P >> applies to non-paradoxical subregs but I might be swapping things - maybe >> you remember better and whether that would cause any issues here? > > So I looked into the history of the code in ifcvt.cc, this code was > added with r6-3071-ge65bf4e814d38c to accept more complex bb > (https://inbox.sourceware.org/gcc-patches/559FBB13.80009@arm.com/). > The thread where we start talking about subregs is located with Jeff's > email starting here: > https://inbox.sourceware.org/gcc-patches/55BBAFAC.5020608@redhat.com/ . > > Jeff, > I know Richard already approved this patch but could you provide a > second eye as you were involved reviewing the original code here and I > want to make sure I understood the code in a a reasonable fashion? It's been a while. I think my original concerns were with RMW operands and making sure we tracked all sub-components of such operands correctly. That was based on the original version, but that version looks like it should have been OK after reviewing the details of reg_referenced_p. It's since moved to DF. So the only worry I immediately see is whether or not DF is giving uses and sets of sub-compenents of a RMW operand or multi-hard register modes. Jeff
On Thu, Jun 1, 2023 at 7:36 AM Jeff Law <jeffreyalaw@gmail.com> wrote: > > > > On 5/31/23 15:22, Andrew Pinski wrote: > > On Wed, May 31, 2023 at 12:29 AM Richard Biener via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > >> > >> On Wed, May 31, 2023 at 6:34 AM Andrew Pinski via Gcc-patches > >> <gcc-patches@gcc.gnu.org> wrote: > >>> > >>> After r14-1014-gc5df248509b489364c573e8, GCC started to emit > >>> directly a zero_extract for `(t1&0x8)!=0`. This introduced > >>> a small regression where ifcvt would not do the ifconversion > >>> as there is now a paradoxical subreg in the dest which > >>> was being rejected. Since paradoxical subreg set the whole > >>> register, we can treat it as the same as a reg in the two places. > >>> > >>> OK? Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu. > >> > >> OK I guess. I vaguely remember SUBREG_PROMOTED_UNSIGNED_P > >> applies to non-paradoxical subregs but I might be swapping things - maybe > >> you remember better and whether that would cause any issues here? > > > > So I looked into the history of the code in ifcvt.cc, this code was > > added with r6-3071-ge65bf4e814d38c to accept more complex bb > > (https://inbox.sourceware.org/gcc-patches/559FBB13.80009@arm.com/). > > The thread where we start talking about subregs is located with Jeff's > > email starting here: > > https://inbox.sourceware.org/gcc-patches/55BBAFAC.5020608@redhat.com/ . > > > > Jeff, > > I know Richard already approved this patch but could you provide a > > second eye as you were involved reviewing the original code here and I > > want to make sure I understood the code in a a reasonable fashion? > It's been a while. I think my original concerns were with RMW operands > and making sure we tracked all sub-components of such operands correctly. > > That was based on the original version, but that version looks like it > should have been OK after reviewing the details of reg_referenced_p. > It's since moved to DF. > > So the only worry I immediately see is whether or not DF is giving uses > and sets of sub-compenents of a RMW operand or multi-hard register modes. So I looked into the code some more, for bb_valid_for_noce_process_p, we are checking to make sure if a reg that was being set is not used by the comparison (and it works using reg_overlap_mentioned_p that satisfies the multi-hard register mode use case and satisfies the RMW case as we are just checking to make sure it does not do that to the registers of the comparison). For bbs_ok_for_cmove_arith, having the check as paradoxical_subreg_p (rather than a plain SUBREG) satisfies RMW operand case (as it is not a RMW operation) and DF already handles multi-hard register when using FOR_EACH_INSN_DEF/FOR_EACH_INSN_USE (and a paradoxical hard register is an invalid RTL in the first place). I wrote this up more to convince myself this is safe and for future references for others when looking into the code to understand it. Thanks, Andrew > > Jeff
diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index 868eda93251..0b180b4568f 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -2022,7 +2022,7 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block bb_b, rtx to_rename) } /* Make sure this is a REG and not some instance - of ZERO_EXTRACT or SUBREG or other dangerous stuff. + of ZERO_EXTRACT or non-paradoxical SUBREG or other dangerous stuff. If we have a memory destination then we have a pair of simple basic blocks performing an operation of the form [addr] = c ? a : b. bb_valid_for_noce_process_p will have ensured that these are @@ -2030,7 +2030,8 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block bb_b, rtx to_rename) to be renamed. Assert that the callers set this up properly. */ if (MEM_P (SET_DEST (sset_b))) gcc_assert (rtx_equal_p (SET_DEST (sset_b), to_rename)); - else if (!REG_P (SET_DEST (sset_b))) + else if (!REG_P (SET_DEST (sset_b)) + && !paradoxical_subreg_p (SET_DEST (sset_b))) { BITMAP_FREE (bba_sets); return false; @@ -3136,14 +3137,17 @@ bb_valid_for_noce_process_p (basic_block test_bb, rtx cond, rtx sset = single_set (insn); gcc_assert (sset); + rtx dest = SET_DEST (sset); + if (SUBREG_P (dest)) + dest = SUBREG_REG (dest); if (contains_mem_rtx_p (SET_SRC (sset)) - || !REG_P (SET_DEST (sset)) - || reg_overlap_mentioned_p (SET_DEST (sset), cond)) + || !REG_P (dest) + || reg_overlap_mentioned_p (dest, cond)) goto free_bitmap_and_fail; potential_cost += pattern_cost (sset, speed_p); - bitmap_set_bit (test_bb_temps, REGNO (SET_DEST (sset))); + bitmap_set_bit (test_bb_temps, REGNO (dest)); } } diff --git a/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c b/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c new file mode 100644 index 00000000000..c3b8a6f45cc --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/csel_bfx_2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +unsigned +f1(int t, int t1) +{ + int tt = 0; + if(t) + tt = (t1&0x8)!=0; + return tt; +} +struct f +{ + unsigned t:3; + unsigned t1:4; +}; +unsigned +f2(int t, struct f y) +{ + int tt = 0; + if(t) + tt = y.t1; + return tt; +} +/* Both f1 and f2 should produce a csel and not a cbz on the argument. */ +/* { dg-final { scan-assembler-times "csel\t" 2 } } */ +/* { dg-final { scan-assembler-times "ubfx\t" 2 } } */ +/* { dg-final { scan-assembler-not "cbz\t" } } */