From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2051.outbound.protection.outlook.com [40.107.22.51]) by sourceware.org (Postfix) with ESMTPS id 1D0CF3858C83 for ; Mon, 26 Sep 2022 14:02:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D0CF3858C83 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=IgOZVAWZ/G3aVFoaIGT61TlXTiaYLAR+kL9sWzCGCAXATxkPrbup/AWn+KoBX4PZFX24WB2xr26jMC244Z0srglZ831bmO8poybscz/ai5m57F8SNdX/A3aTjo0o6uIRoSTqxmT7hrE+n/65kcaHWA3lxbABkC9E1bHK2h6MbzrAp+jDCw/Ur3m86Vag2LVHWJGlQv7UysC+GePBqFc78hI4ofN7DByeJl7yBGYqM1ysbK2yO7vu2Am088FbuilI6rrUYaQctrRgQoQ5ALZ8Wzh8UBYLC7whIc7MUQ51YzyG325ugzEV3NHAPC+QkDXzDGdLUlL/AFfLrtwQvMyzbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ykl2hzGI9Skkl6d9KycOXPLQ/TKypmN/5rtD7uc16I4=; b=Kl7hene6HBIhJsvbMIM/Du+tFkRyWj4/RfjJL81pR3s+EoqDyHYQK7CrwcfFp234/zE62gc/GaLKrVPs1qXZ1B6K2BuLWnw8G81aFv5aCeOpZVTTTSdU4mt4GIa2jAqckv7X63QcbSkkZFopEuNrZvOq9AvRMZqFX+V0nxHo7EDm/Dwryexnrxf/XK1RediEhtITyxXehm1MrBrtGLsfFgJRzvvbjX1OZd5JYqiJMKEebm8ySmb/PRgjwDWiQjxfpxUulaskmH+GLTJCRSgrJBO2eQzXgamoU1Xx6XSRjtBuGXtiAeraVIqAVL3mROxPCj8pMBFltcI5F8yuXQXGfw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ykl2hzGI9Skkl6d9KycOXPLQ/TKypmN/5rtD7uc16I4=; b=fvCzbovv5Lpz7qSiCtPEPsj9lvrkVT8towfWLBQ8BHMi9TGJYzt1uXa7AF8zumGZ7exsnzpwsV37mTK4JTD6YI9cBwS2bvaYNmTiVmKoRPks7Py6uotqDELtNddT8MXr6ES15U+3SwDguBM5Avl/hGiQNTlevZ2UVEnJOJ5FI6Y= Received: from AS9PR06CA0460.eurprd06.prod.outlook.com (2603:10a6:20b:49a::9) by DU0PR08MB8561.eurprd08.prod.outlook.com (2603:10a6:10:406::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:02:25 +0000 Received: from AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49a:cafe::5a) by AS9PR06CA0460.outlook.office365.com (2603:10a6:20b:49a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25 via Frontend Transport; Mon, 26 Sep 2022 14:02:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT026.mail.protection.outlook.com (100.127.140.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:02:24 +0000 Received: ("Tessian outbound 0a0431bdcdb4:v124"); Mon, 26 Sep 2022 14:02:24 +0000 X-CR-MTA-TID: 64aa7808 Received: from d10f342c667b.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6D5031D9-3B58-41F9-9C02-B999F6E24BC4.1; Mon, 26 Sep 2022 14:02:14 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d10f342c667b.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 26 Sep 2022 14:02:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V3+bCH6LvkgXSFHcRkWI3fGwTOhkliLizQyriyGDL1cl6WbVpPyGccOxXEn9JSZFHugxywLEjycajqhP6hMOLDFMhsZcBz8NK2Lh25cPpVHkFF7kVcNqnbB6xh1x9c/eFBFk1Q9o65r7k2IioEaEc76u2wSSAKkBWFLAZ95w4rv2F+HXt4nuajOOcOyev2BJ1ky/l2qlk60BUCXLktMnA4OBhkVz0q2W/83EzUqwll4bmxgsf1N8wXcHGNbFvtBGERWB3ZbHM85ipaztdWG+Aw0WOY++v/DgoFVX0IRZfTTuRDZ5PsKKMFrNelqnr3h8Bf3XSLIfoy2GCyrZ92bEwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ykl2hzGI9Skkl6d9KycOXPLQ/TKypmN/5rtD7uc16I4=; b=IAxPH3ekVNn8EBgtP0VCJLTDOBKMRsp7l5YCnGkQ9JJhJmtACElLcn+RU1qKM3GMA2/wvTA9AwbRRK1M8LPrAphjgR10AfGUkSW23XLcXFMw9VSSb/gqbOLcBN0dqdfUkH0jUdlDgLKYa95nUB+ej76m5hHtFm85sFkmaUN7pch3bqwChk4R+M5Bo8el8Y5M8dJiuVoeGe/rh9fk2EY047NEBT9jyfG1U87CCqc0GdMp+ZpVvWuhfQSyuvocs6V+iPVDNNf3YQfehAf1aFHdgA0YEIFfPuUapqWJ6G5/i6eXAqnLl2AyM7VkqQukUacwz7FqnicI9bLJF/HIVcLdwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ykl2hzGI9Skkl6d9KycOXPLQ/TKypmN/5rtD7uc16I4=; b=fvCzbovv5Lpz7qSiCtPEPsj9lvrkVT8towfWLBQ8BHMi9TGJYzt1uXa7AF8zumGZ7exsnzpwsV37mTK4JTD6YI9cBwS2bvaYNmTiVmKoRPks7Py6uotqDELtNddT8MXr6ES15U+3SwDguBM5Avl/hGiQNTlevZ2UVEnJOJ5FI6Y= Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by PAXPR08MB7420.eurprd08.prod.outlook.com (2603:10a6:102:2b9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24; Mon, 26 Sep 2022 14:02:11 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::6529:66e5:e7d4:1a40]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::6529:66e5:e7d4:1a40%4]) with mapi id 15.20.5654.022; Mon, 26 Sep 2022 14:02:11 +0000 From: Tamar Christina To: Richard Biener CC: "gcc-patches@gcc.gnu.org" , nd , "jeffreyalaw@gmail.com" , Richard Sandiford Subject: RE: [PATCH 1/2]middle-end: RFC: On expansion of conditional branches, give hint if argument is a truth type to backend Thread-Topic: [PATCH 1/2]middle-end: RFC: On expansion of conditional branches, give hint if argument is a truth type to backend Thread-Index: AQHYzy5cPtP/U576lE6Yh3eQBn/QMK3xiPyAgAAF5FCAAAoggIAAAUohgAAP6ICAAAKJAIAAEpAQ Date: Mon, 26 Sep 2022 14:02:11 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 45395F6D3EBD6F4F86060A088EDB8584.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: VI1PR08MB5325:EE_|PAXPR08MB7420:EE_|AM7EUR03FT026:EE_|DU0PR08MB8561:EE_ X-MS-Office365-Filtering-Correlation-Id: 85aaa899-b6fd-4787-7ac8-08da9fc7bd48 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 3yl1lJFbfqPKxX2XZCDKlc4BXx+zA5ezxIaeJlHLInQrR7n0tEhu7Jvwe3lEu+3/vwU4oU2XhWIm5h4vIuKnVPB0lR0Q1jgcyyx2RT9jU27lDccBdIzXx0vm106vjffakEPKW/tu7Oc0EyXR4g9FEFDKLRaqyIULpJgqjEpTixbcuIyBxQ26qSRTAx+XKQKtvSTkmU0ak/YWS/Vjmc6VJiTSaXYLsUTh51JvzuIKXkwi6nsWuueouyc0GE4ZGmB/k4Zk1lc5jZqGieiXY7Wuzk4MKIk6lQF3d8K4ee/fyTORE6FmKVj/4r5x1tLEeJrhM/uvkt6mc2H5Y3Gv+6ltjAfXhJfSzBL0s+lsxYj3TlP3/aTp6o2iEUTbp3xS8vxaWUcF01FI2l0JaVJ4qhnB3YkzYYdohBuGVbx6vFzmEKzO4NlQ65sZeW1KgZWSktTKy2Sq0GdaFZoIO/IElSYiiLs5ExJVGIUIhdritQRFGpyskiaXKlkS++yvAV113fMSKeCsXJnKObK0nuHhbV81wrgSt25cw7bxLtHc9TYfrA0JUPtapW3ySxrNNv4cbLGG4sYZ1NxRpEk7dbW2QVNncg0jaWf8UMKpO93q5I4KOZaUAM/fykToS6xpmaHa3gXoxCDp0JIHSod16hAfAJ0/f+tftyd4qbRCO7nS5oi4EyNTzCn4eJfi1FGA3gAnQvTnyb22LFV/cVc1q/crNe6yQpjM+kVWFILF9dlNy9ESkiACmdldF/v03OVGZIc1J/TGkUaaOwf1RorxFU4KKJCdcQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB5325.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(376002)(39860400002)(396003)(136003)(346002)(451199015)(55016003)(316002)(4326008)(8676002)(38100700002)(76116006)(66476007)(66446008)(66556008)(64756008)(186003)(33656002)(66946007)(122000001)(478600001)(26005)(9686003)(6506007)(53546011)(7696005)(6916009)(54906003)(83380400001)(71200400001)(38070700005)(5660300002)(86362001)(2906002)(41300700001)(8936002)(52536014);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7420 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a652efd3-cd38-413d-f1e8-08da9fc7b55c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PpzVMbUT0zcmy5whAiwVRpS1A0xoBC41JA9/2LgRMRm0j3uDqVs1ak0ig5SYt+lm8ZA85VkN1yK4FDXlVKX+/DyHQjetrF25g+lWvDT8RkfWMrtbiGfnkczwq87O0Q1x/Vhj7iyTAxaHsCZSJoJkH+pOT+z2dQuUjK2vC5xC8qaLFOJ5SYejaEN1O+6GsiXKcH/vrfUiFE7k7Xta0YyFeleMYywhbPbLN87P+ANldX48gZ43HTmG1RRYHt5DljDlx1u4VcH7MzESFl1pdHgY8/hEAvjdISatGLXSt+5jNs4ybcnp/6uxeb486NfBFYVaBYriTC+WwtRmKEPbQuabjWc7tRbKVpjN4HANBYT7eHYecSBo2qlRU4goxurjGFYD8IFjsTvdC1h+aPkUfeEl3pmkVlTd3o0DpHxnijzqXBCZRJShKCxA3M1OrAeld5PdTTRRangOAlzzOtSRrUFpMhK6C5D4IgWXMhVBW04uW/S8JyT0KUIloNC/d2nfwIs59FFw24Fthoapeg0MuipBtgpgeKDPEWaM6Z/Seq3EF7VQr8FTZ5PLggezRCy3X8JdLSvSdX+K/whow30i1ZBcwfz4dR3UNM+kwLzAXMTkzCC5oZfno5zlZL/kdk4bcbnpP0PwHPyFAJ24LfTnls4naf+AZKebQEhm7vnXlTZ5o5/7U/IDG7/RGinDvlTPcyW8NrLQLm0S36YWA5cZ9eo5dNzmZRPE9Z/YMg8pm8r2LHT/UvmHWhvtkC2CuyHem88qq/NBxa3i/OgQcKOpHvoIsg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199015)(36840700001)(46966006)(40470700004)(33656002)(82310400005)(55016003)(40480700001)(47076005)(336012)(83380400001)(41300700001)(7696005)(26005)(9686003)(186003)(6862004)(356005)(52536014)(8936002)(5660300002)(2906002)(86362001)(40460700003)(54906003)(70206006)(316002)(8676002)(6506007)(36860700001)(53546011)(478600001)(81166007)(70586007)(82740400003)(4326008);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:02:24.8829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85aaa899-b6fd-4787-7ac8-08da9fc7bd48 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8561 X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,THIS_AD,TXREP,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > -----Original Message----- > From: Richard Biener > Sent: Monday, September 26, 2022 1:43 PM > To: Tamar Christina > Cc: gcc-patches@gcc.gnu.org; nd ; jeffreyalaw@gmail.com; > Richard Sandiford > Subject: Re: [PATCH 1/2]middle-end: RFC: On expansion of conditional > branches, give hint if argument is a truth type to backend >=20 > On Mon, 26 Sep 2022, Richard Biener wrote: >=20 > > On Mon, 26 Sep 2022, Tamar Christina wrote: > > > > > > Maybe the target could use (subreg:SI (reg:BI ...)) as argument. He= h. > > > > > > But then I'd still need to change the expansion code. I suppose this = could > prevent the issue with changes to code on other targets. > > > > > > > > > We have undocumented addcc, negcc, etc. patterns, should we > have aandcc pattern for this indicating support for andcc + jump as > opposedto cmpcc + jump? > > > > > > > > > > This could work yeah. I didn't know these existed. > > > > > > > Ah, so they are conditional add, not add setting CC, so andcc > > > > wouldn't be appropriate. > > > > > > > So I'm not sure how we'd handle such situation - maybe looking at > > > > REG_DECL and recognizing a _Bool PARM_DECL is OK? > > > > > > I have a slight suspicion that Richard Sandiford would likely reject = this > though.. The additional AND seemed less hacky as it's just communicating > range. > > > > > > I still need to also figure out which representation of bool is being= used, > because only the 0-1 variant works. Is there a way to check that? > > > > So another option would be, in case you have (subreg:SI (reg:QI)), if > > we expand > > > > if (b !=3D 0) > > > > expand that to > > > > !((b & 255) =3D=3D 0) > > > > basically invert the comparison and the leverage the paradoxical > > subreg to specify a narrower immediate to AND with? Just hoping that > > arm can do 255 as immediate and still efficiently handle this? We can and already do, and don't need that representation to do so. The problem is, handling 255 is already inefficient. It requires us to use = an additional Instruction to test the value. Whereas we have a fused test single bit and = branch instruction. > > > > Wouldn't this transform be possible in combine with the appropriate > > backend pattern and combine synthesizing the and for paradoxical > subregs? Not unless we have enough range information in RTL to know that whatever va= lue has been fed into the cbranch has a range of 1 bit. A range of 8 bits we alread= y have and isn't value useful. The idea was to transform what we currently have: tst w0, 255 bne .L4 ret i.e. test the bottom 8 bits, into tbnz w0, #0, .L4 ret i.e. test only bit 0 and branch based on that bit. We cannot do this when a= ll we know is that the range is 8 bits. >=20 > Looking at what we produce on aarch64 it seems 'bool' is using an SImode > register but your characterization that the upper 24 bits have undefined > content suggests that is a wrong representation? > If the ABI doesn't say anything about the upper bits we should reflect th= at > somehow? It does. And no "bool" is using QImode. The expansion of extern void h (); void g1(bool x) { if (__builtin_expect (x, 0)) h (); } Shows that the argument x is passed as a QI mode, but like many RISC target= s (and even i386) we promote the argument during expansion: (insn 2 4 3 2 (set (reg/v:SI 92 [ x ]) (zero_extend:SI (reg:QI 0 x0 [ x ]))) "/app/example.cpp":4:1 -1 (nil)) But the value is passed as QImode. We use this fact to know that the range is 8 bits in the cbanch instruction= . If no operation was done that requires a bigger range then combine will push the zero extend into the cbranch and we have v= arious patterns to handle different forms of this. For instance: void g1(bool *x) { if (__builtin_expect (*x, 0)) h (); } Because of the load of x we generate: ldrb w0, [x0] cbnz w0, .L7 ret because we know the top bits are defined to 0 in this case and can just tes= t the entire register. The reason for this promotion for us and many other backends is one of effi= ciency. If we don't promote to something we have native instructions for we would have to promote and demote the val= ue at *every* instruction in RTL. This causes significant noise in the RTL. So we can't do anything differen= t here. I have plans to try to fix this, but not in GCC 13. But even then it won't help with this case, because we explicitly need to k= now that the range is a single bit. Not 8 bits. Regards, Tamar >=20 > Richard.