From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80084.outbound.protection.outlook.com [40.107.8.84]) by sourceware.org (Postfix) with ESMTPS id 69153385AE72 for ; Fri, 15 Jul 2022 14:18:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 69153385AE72 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=cEZUPhWzyjO4fh/rBgGpewnz26/hTzWEGTH9COlM3Z1w6yDdbaQchYAK53G4laVQ4lmlWAfOekYSsyWJlbh3kLmps0On/Hxy0IeoHMWDkSC4hdiCNMbaIN2z9MhHOYWCj9IF3gdS5cdRJ7lbAAnL8zwv83cq1/DMB9NG4onjYdrwNmOhVl8HgoyRr8itvONTag7/o0a+yMAHc/1yohe8noH2y2O82ehZv1S9e+cTJzQb+uYYM79dw6w7Ah9D5qM0ZlT64pYHnn2tjqqeISK2bTL6Q33OtqQwPUT8SYzmIbzZAo0dio98/1sS6fL4D5CVevOJXfGNVfvJsOPBq/JoCg== 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=Z3z4Ya8aOCJjoJKvCGjNH0IdBEfo3DLweqVXr6PYFDM=; b=KoU/XcVL98Z+CgzWNZXCA2ROPAcvHCvOY+TZhUtA6mnNKvqyIoVesivhGjgIhb+gMvuH9mrLYpDR0IA+ZdO/DIgmHgTAT2K4iHWVZpFQPg+tE8xCYq41R6MNAabg+K9U2pmYczJZpdlIp/fyIm5KyY+0O/CosKUW9osn8j315//0LTJFu3xI1NYZG1qTpAkegkjVyHZqUp+bx6Jst7VvFJE7iUPU13wN67LKm/ka2/1FYKVGHeVjjT7AdyVkv/3oLsOwR80hVqWoEEJ5pTd9RDaGrD3I5Bbk2tfmCoH6TPEXxyYijoHrtsRauoOUFJ8BKziPLmgl/dEKTTgM/eQcmA== 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]) Received: from AM5PR0301CA0029.eurprd03.prod.outlook.com (2603:10a6:206:14::42) by DB6PR0801MB2022.eurprd08.prod.outlook.com (2603:10a6:4:76::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.15; Fri, 15 Jul 2022 14:18:03 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:14:cafe::e2) by AM5PR0301CA0029.outlook.office365.com (2603:10a6:206:14::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.19 via Frontend Transport; Fri, 15 Jul 2022 14:18:03 +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 VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.12 via Frontend Transport; Fri, 15 Jul 2022 14:18:03 +0000 Received: ("Tessian outbound fccf984e7173:v123"); Fri, 15 Jul 2022 14:18:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ba2fcb9499438780 X-CR-MTA-TID: 64aa7808 Received: from d186f63eda29.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 98F3A8D7-9627-4B4C-A36B-9774D1D92F62.1; Fri, 15 Jul 2022 14:17:55 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d186f63eda29.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 15 Jul 2022 14:17:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XyUf0gvgfzBYoYGK2/V8nzueOizmh1cbJNdXiSY3yLLixjJ1/HbFccC09V/Qq2AkuDWVcTNfgBcac9I0lFoPz9OajdNNxhcIu8Vg5NOz0VydS+PmBfjqtQrwRrx8/yIaI9RUuYdxUdtQGYh98F70sAxkxRaz4aiaMjTQr5ny/p0Fi0geb18wIvq+7scd5xeqhI0q8iuQ9UPc3oNEjPNARdBujMuRk6TUqYu7KgPxgMeTOxxesQK3AIjfiB6dXI6dlz+XO6+5GBO3LtAYz8iNx9Auff7mJ4slhOQldvQsBkiC9UnMX4gcFjBlZS8wxF7Lcg2bxjqOq0kWmE2511mpzw== 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=Z3z4Ya8aOCJjoJKvCGjNH0IdBEfo3DLweqVXr6PYFDM=; b=NpaXpAcGZJmCGFlIhAxiC5XyR2DR8zFPi7H2Q15k4iVxblts9p/tXd+bJve+4W0YsDSDWYXVgeOCnjfftX9bCCL3FhOAqqBrDxkW1xhomNVp22+zVmPe+e+xdvRxum8e82Ps7X6zHMYiDzZaPBq8JMD/hH9Kz/k5VvH8jGbHwN98dVg/PIGr+MxcTcqlI5pxOnsEwPwNbk5M8I2/DxCTIeARo0AvLNJoXvxwSpdyu21ykQP23EDd1TeJW7/50xUV/ie3lcvBdRzIFifa108NNPGlgJ7X9tFPlz/uw7B2f8C9UAmfj7PpMc6f/s3VcC+tCKCfaKURi0BMw1fvRDejBg== 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 Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) by VI1PR0801MB1824.eurprd08.prod.outlook.com (2603:10a6:800:50::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.15; Fri, 15 Jul 2022 14:17:53 +0000 Received: from AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::90e1:2317:2ab:bd1e]) by AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::90e1:2317:2ab:bd1e%9]) with mapi id 15.20.5438.012; Fri, 15 Jul 2022 14:17:53 +0000 Date: Fri, 15 Jul 2022 15:18:01 +0100 From: Andrew Carlotti To: Richard Biener Cc: Richard Biener via Gcc-patches , Richard Sandiford Subject: Re: [PATCH v2 1/2] aarch64: Don't return invalid GIMPLE assign statements Message-ID: References: Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO2P265CA0003.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::15) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 44c39c5e-ee31-4a25-1a94-08da666cd477 X-MS-TrafficTypeDiagnostic: VI1PR0801MB1824:EE_|VE1EUR03FT053:EE_|DB6PR0801MB2022:EE_ 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: OkXypcvJrJtSiPeWU5dIq7VYEFO02D54RQ6vT7leSYORXUUm9GY/9RNBl1dmn1n/Mz6MGYtOexcVScBR9livgtr4P+0NTMGk3G/xElg2wFN4qx5hqiS4QEjJRtCQpmfp7lATAOsGhiJ/e8XvDPcyiloY3bygEX19LPF3xUZUTt3zL8VZf8V54RHL4Hn41Cg8sDRoHUPkeMnz+czMb3e0eYgdElAqdeCIkaNs5cDa5vFdfbQSydJ/x8GmPlLhu4waIboz4Vnd0j8TjfFeg/6B/Jkxd3YOLpeLEsGum9DDwuxP3CNEPqk3sLKuJGxJNVJ4Ynrtppsyh4nyDRzW/CwpEBh6JsD9MPbkU4+de4w9qO/UioPAayOUk2Ooo4aK28lO/W+bBDNxAL5WtwiizB2Jjm/s9KzztTG/Z+8HYqXmYdFG+fxmSBy2Ke9pMxnCoav62rms8y6OB+4lTyDd6gN9x1ssWJXdJzBRyAB0EhiF9qf19RxEdFxqfiOp1KWK3ODWSz8xKMapXk5m2AqdL5E+UBZjlpiZEP/1jtL7KVtk76TbgB7fGuzN521f9Jq4uYqFKmv2ch94aZfZwUXV5Q+sLu6U8WUnnogbmftOeNSVcorOtswzsNaHocvnFYQzwXDuwxUSsIhFsi7gPY1IA9XWddx6VlvgQPAkCKlwOhPZpZ8I5fBUlwFIsS8VI5QaUq4EEtVP0pzwy4zzOfbGJrRi0vw75kMRZtjxmh2WXXxH0yhW88bloZieZcGLeUcz5sjBhQsGc30m4p+yPUMs0c3RpA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6678.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(396003)(376002)(136003)(346002)(39860400002)(5660300002)(44832011)(2906002)(8676002)(8936002)(54906003)(4326008)(83380400001)(66556008)(86362001)(38100700002)(478600001)(6486002)(53546011)(6512007)(6916009)(66476007)(66946007)(186003)(6666004)(26005)(41300700001)(6506007)(84970400001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1824 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 71d6719d-dc4b-43bb-33a5-08da666cce56 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D+/wniHhJIwICD7ZIstTPzJhIggCxJE3AxITkbiK0MurSlh03HHERfnFAr2rMtuVjv19AwbO5S6KtbU2XtviX+Z5hrOb0tzojH8vkQrX3Ocf3JtKH2OHnUvcJPwOGmWCKui4IdQAGwPxivVAEksfqktyYm883mBmZKoI6COCs94oF3Wl284uHvOqmTiz9VxD2/ebjtTLoiOU98LQW+6nsqZtmK5M0/EuOO2MZM+cERD6borWC55IlWb7WkLmnzKAmnSGUXrTH/LeyQyRrPhnlqUJvT0rUzZ8yHuqrdZMB1vzgV55tyiBiDYFyl9UFPxrqkLmcUhD9LGiW6ptC02jQCsXqw3XbN53GjHqjrOy39hQk8TIGOQlzC2atiLd9SX70WmLllQTFMpUKlXDI7vwQStc1zc7vk67AXLKSMOK9g5PMcnoeXYX8HY5HDXjOceP22HGxLiLPmuixLW/fHv6J74SDEWLfYAPlw3ng82mbiGVtO6EA2XSfGsJ7x6yXowcHMw3hodw18MznJBGVFNuwBgMn1u+BCl9z+h13Y099WhTkQo3Nt0sI2ZAXwqQWWyZFEqtW3lqMiOaJT6vw00rZTAgBy42K20N52v8XAISO7K91PeeCKAqX5ddCg4u8mG54k8tgVJFsUNVY2qgXdEaAlb+jl2hiu5wUeWJDK+m4ZiKcwghLNKmpSY9VknUj/LKerfDYITlUxX5okn9L4FoaZt1+OQWBevrsY6vkMe4sDKap5VIPtB2Nm/i4Mxdayw3+ch6Ckb/4zfREAxareoXNXeBiogiM2i2jfwxR1S/700J5LAc4i2UPugJ4xrDI02T50oWt2d4rU/s6uNR/D25xh2H//HPExpBGZsGBc3iWl0= 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:(13230016)(4636009)(346002)(136003)(376002)(396003)(39860400002)(40470700004)(36840700001)(46966006)(186003)(82310400005)(478600001)(356005)(41300700001)(84970400001)(53546011)(6486002)(86362001)(6506007)(26005)(6666004)(336012)(40460700003)(36860700001)(40480700001)(2906002)(6512007)(81166007)(82740400003)(83380400001)(44832011)(6862004)(47076005)(5660300002)(8936002)(70206006)(4326008)(8676002)(54906003)(70586007)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2022 14:18:03.2269 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44c39c5e-ee31-4a25-1a94-08da666cd477 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2022 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2022 14:18:08 -0000 On Wed, Jul 13, 2022 at 02:32:16PM +0200, Richard Biener wrote: > On Wed, Jul 13, 2022 at 12:50 PM Andrew Carlotti > wrote: > > I specifically wanted to avoid not folding the call, because always > > folding means that the builtin doesn't need to be implemented anywhere > > else (which isn't relevant here, but may become relevant when folding > > newly defined builtins in the future). > > > > I considered dropping the statement, but I wasn't sure at the time that > > I could do it safely. I could send a patch to instead replace new_stmt > > with a GIMPLE_NOP. > > If you can be sure there's no side-effect on the RHS then I think > I'd prefer that over allocating an SSA name for something that's > going to be DCEd anyway. > > Richard. I discussed this off-list with Richard Sandiford, and we agreed that it would be better to leave this code as it is. The only time this form is likely to arise is if the statement has side-effects (e.g. reading from volatile memory or triggering floating-point exceptions), in which case we can't just replace it with a nop. On the other hand, in the event that someone has written an entirely redundant statement, then it will quickly get eliminated anyway. Adding code to distinguish between the two cases here, or to handle the hard case, is unnecessary and wouldn't be worthwhile. > > > >> gcc/ChangeLog: > > > >> > > > >> * config/aarch64/aarch64-builtins.cc > > > >> (aarch64_general_gimple_fold_builtin): Add fixup for invalid GIMPLE. > > > >> > > > >> gcc/testsuite/ChangeLog: > > > >> > > > >> * gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c: New test. > > > >> > > > >> --- > > > >> > > > >> diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc > > > >> index e0a741ac663188713e21f457affa57217d074783..5753988a9964967c27a03aca5fddb9025fd8ed6e 100644 > > > >> --- a/gcc/config/aarch64/aarch64-builtins.cc > > > >> +++ b/gcc/config/aarch64/aarch64-builtins.cc > > > >> @@ -3022,6 +3022,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt, > > > >> default: > > > >> break; > > > >> } > > > >> + > > > >> + /* GIMPLE assign statements (unlike calls) require a non-null lhs. If we > > > >> + created an assign statement with a null lhs, then fix this by assigning > > > >> + to a new (and subsequently unused) variable. */ > > > >> + if (new_stmt && is_gimple_assign (new_stmt) && !gimple_assign_lhs (new_stmt)) > > > >> + { > > > >> + tree new_lhs = make_ssa_name (gimple_call_return_type (stmt)); > > > >> + gimple_assign_set_lhs (new_stmt, new_lhs); > > > >> + } > > > >> + > > > >> return new_stmt; > > > >> } > > > >> > > > >> diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c > > > >> new file mode 100644 > > > >> index 0000000000000000000000000000000000000000..345307456b175307f5cb22de5e59cfc6254f2737 > > > >> --- /dev/null > > > >> +++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/ignored_return_1.c > > > >> @@ -0,0 +1,9 @@ > > > >> +/* { dg-do compile { target { aarch64*-*-* } } } */ > > > >> + > > > >> +#include > > > >> + > > > >> +int8_t *bar(); > > > >> + > > > >> +void foo() { > > > >> + __builtin_aarch64_ld1v16qi(bar()); > > > >> +}