From patchwork Tue Dec 14 09:43:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 48891 Return-Path: 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 9D3A6385841D for ; Tue, 14 Dec 2021 09:44:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D3A6385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1639475071; bh=Zu0xGTuUdcxk6X9rZlWMWChE63OAZHP2hQyyrhVeHIw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=JmkGhZk+WPvMqBPML9gWoOVHvYCAlo3+Th/5/r6M/fh91ygFYwsWhGNNRYyV9D/z2 Y/kGL9+jEtrPbHbs9Ow4IPSArgfaavNeOLOE4txOYtmMEMF7Dq+ENqeIURlVHKo9wb Mx3QgXgt8ocTm9DBF0QDkQ1n2Ur7cK5aX/md2Tdk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60086.outbound.protection.outlook.com [40.107.6.86]) by sourceware.org (Postfix) with ESMTPS id E7B403858D28 for ; Tue, 14 Dec 2021 09:43:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E7B403858D28 Received: from DBBPR09CA0034.eurprd09.prod.outlook.com (2603:10a6:10:d4::22) by PR3PR08MB5594.eurprd08.prod.outlook.com (2603:10a6:102:8b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.16; Tue, 14 Dec 2021 09:43:55 +0000 Received: from DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:d4:cafe::ab) by DBBPR09CA0034.outlook.office365.com (2603:10a6:10:d4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.15 via Frontend Transport; Tue, 14 Dec 2021 09:43:55 +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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT020.mail.protection.outlook.com (10.152.20.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12 via Frontend Transport; Tue, 14 Dec 2021 09:43:55 +0000 Received: ("Tessian outbound 1cd1a01725a6:v110"); Tue, 14 Dec 2021 09:43:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d62bb38e468f98e4 X-CR-MTA-TID: 64aa7808 Received: from 7a230296c345.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 997D2C21-8624-4063-ABF6-C805D96CB4A5.1; Tue, 14 Dec 2021 09:43:37 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7a230296c345.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 14 Dec 2021 09:43:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PUyd4C34ANn497EoD9wyShOANI1e8J5W4gvK3U4pSYMIgRgDoBTNK972YKD/TUU3HGDeVOU9VX246Rva31/j/gzKaFgyN62ZzV4fn8rn5tCj65eZkBdOpdcixz3S5EvOIKH5jhC4T2bI27krIKHNTUb80NDqXG5kp3L6IwAUmlyMleobdn9vdFbo+u1aCnz9LdGfRYs6+rzvyLYod1R8x5U7y+qRXPMBuwLAP3dZTge3o/Si/ecT6l6ILUiitDXuz3kH3sMvR0ninu9a45noehnd1SYSsP2c1UmVKdYIHks7TqfLMQVxp5ypdK/whM3q+g2XYSoXvec3TeOeE1/0gQ== 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=Zu0xGTuUdcxk6X9rZlWMWChE63OAZHP2hQyyrhVeHIw=; b=k9mxtpug0qJ8aZfEMlEAPJw5An9nj+KlGwVM352iPmkfLoRJ2Rmq9Yg9b4yAShgmQHaVri02ATne319CLVIjCADjru9sHeyEIEYhDyDpsFyZeqEoLfnYLCWLOzvn4b8C1qfZVXLMdJhaS4ASpBfJBzKuG7VUlzvgrRMWHHHt9IoSL05RLOIWxvESenEWciscO+6aWFG99XT8JG/mrtVA5lDZS4VoI4qdXewpQXvLKm0p3MvkdN73d4gha7ljz3Vc13+vyaDCN2d42kyH/h5SDsVhpdZkjMFyZXyYGCQ/HBTVJi6AiVTQnRI4PDxr1CMkmKP2WvlBAT+aOJn5/V1hfw== 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 VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by VE1PR08MB4861.eurprd08.prod.outlook.com (2603:10a6:802:a5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.11; Tue, 14 Dec 2021 09:43:34 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::12a:3d2c:81ff:8fcc]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::12a:3d2c:81ff:8fcc%8]) with mapi id 15.20.4778.017; Tue, 14 Dec 2021 09:43:34 +0000 Date: Tue, 14 Dec 2021 09:43:31 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH]middle-end: REE should always check all vector usages, even if it finds a defining def. [PR103350] Message-ID: Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-ClientProxiedBy: LO3P265CA0003.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::8) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e4683986-d7be-48df-80db-08d9bee63e87 X-MS-TrafficTypeDiagnostic: VE1PR08MB4861:EE_|DB5EUR03FT020:EE_|PR3PR08MB5594:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: RLshKSQ8J05tJETp07HhrsI05LWkRxsNbBtwfLu4op3D+PSDVBz5yDffQ8/XzEdaswBEzOHGpCnlgttBc5gPZcOBnl1mH0OineSDrhLS7SXkVns+5EYikXhP0yfj0A6gaF87qxbe6veY4lN/AQ6QalZjcbLonci58CcsRpgeBrIw5meH4uy3JEx8JXi+3JoOQSVKwF/KCFhqoAg9qoAY1s5sC4kyGPSK+XFLEC9cbSKCHq/d7hgxQ5Ug28zyuKXmqKon85+xcfEtnP9G9A09gHm1sAXiZsY5Uy4JBxa7gdxGd0nSovVSVLeoODqd/LYkysyaaBgSTCiFF9gX6K10MTc120WTjUj/UMBEF0xnaCvVWTtWzvfs3IiL3A1e9uezU5RWX9+8NtU2LZ+DSp6QAQwU2KWGIiK/JGd4RZMnay4R+obBPwP5rq+pnHmVUHQLz8LJGx0E9a+2hNYPzHtoYfnbRPZoHAzh7l8bn7f66G2yOAPLFr+/xqTJFJEU+tuKcnrGsqCg7IoN+OXHvk0/aGES5N4tZGC8nP7Jk4zQDnML3jvmS2xANF18J9IRQmiIj8fGbbMXMpiVozGVMmfBz7lZ7dUsvm0nX5n8fAbD0C9tE50O/x2IpjNVctgwqnsIYjPtCSLw/N69jSRXB+OZT2IwPMG31vV+uJxk5QxdfZzqxzZn/oqwfh7r1/vECGIXSLCw4S2/qVXCyEMbb29+ZyslrgZ3ji+Rz35TIXWae8nVlUIt8ro/7WMOu3gRZvHErnNj5tP7+Sh7UX+jj6aqjxO4JXv4UcHKyUjpSxjE1HpP8e5lFhRwWkmJhthNHhQshO+xC5Rq62tD8GBDrYXrBQP9LRGj4XoyJtrree3GQ6w0P3IjlZLcGEx+mDxdVC+8 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:(4636009)(366004)(86362001)(6916009)(44144004)(33964004)(84970400001)(38350700002)(6506007)(8936002)(2906002)(6666004)(38100700002)(36756003)(8676002)(4326008)(66476007)(52116002)(66556008)(6486002)(5660300002)(66946007)(235185007)(44832011)(83380400001)(26005)(508600001)(316002)(186003)(2616005)(6512007)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4861 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: DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 59ef4334-b4fd-4b0e-f59f-08d9bee63231 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bOw7c4psEziasGDO1zzG+uXPOMSu28apbzU+5x+CcWAJKLxCoV3Ax7TdhMAV0wYVpQq0k+2wvrWGDOKFg0+xJvuEgdeuQHdFnMKGM4uXrsAspReEQOO7UndGAzialWqTdcfrSlnwEpenT+mMJ1CJ3VAiEc4QQIclcEudUYZEkfRJeSlFrRkHKsR58NvkblagBrCdsSnnYRoDtVlM0EYqhsm/aZurFEbvK100i15MTMVTWRl7Nly7PbBFRc8dC0x72mdtvtOlYwlxHI0AslTazhLWOpULl6FLxOXOweOKu9MV0Fdsdl6Yc+LP+Aaav8ryihW9mHeYswUTxuCMkMqQ1A6u20YyP8gxq5OKZrckg/c/2+GjIrBIiU+BjwGCJAhL8VahnS0DGenmSc253vsGxGoqJQRpsjCoAW7SBy3jj1knMLuv7Mo1IrOE9EzXfu5A8ZBwbCF9CGz/i35w/L4rUICIS2Rzi7MRs1jDucTqTyJ27VDSzknOc6N2DLmDn7GL8GQ+zRn5eKk2GYVlnZiT2g37Rk2MVRHKfa8MZMhYHJRzRQk4yR3P4RO7XT9NdNp+O/vnC9yooJ5O/8JkBEjpASO0ZU4s/xg6U68pPRKQSQZYIbhg8h43xKOWJsCI5644RWwpbY1GC4/dKcj7SkfogVy2hSKNqKJvsSTNnXpAHtsIBEUS5s0PhzuBpFSlYjDYPf4ks++JMo2//Cr9rHmKjgbooyd+nhmWwSsISBs73hWHvbgH6n1GoyrOWujwdqeyPPR+VF9E6yl0er/6CWyDm9L26laiaq0IrghRToLJCpnq1Tq0Q6xp0HSL7p8jL0dhdjjuPLKRgo54pMut5nOPewS4oGCm4mFHJa9yVAuhfl846i3xejJckLpg8MXEwMlRfsKEQwZdHK2mGzk/XvOGHcdAQBkgpZKavP6R3Ks9zT/936kYzsS8W2JIN1HgoFjr 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:(4636009)(36840700001)(46966006)(40470700001)(8676002)(36860700001)(82310400004)(83380400001)(84970400001)(316002)(6512007)(508600001)(40460700001)(8936002)(5660300002)(4326008)(44832011)(44144004)(33964004)(86362001)(235185007)(6486002)(36756003)(70586007)(336012)(70206006)(2906002)(47076005)(356005)(6506007)(2616005)(81166007)(186003)(6666004)(26005)(6916009)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 09:43:55.0374 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4683986-d7be-48df-80db-08d9bee63e87 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: DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5594 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina Cc: rguenther@suse.de, richard.sandiford@arm.com, ian@airs.com, nd@arm.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi All, This and the report in PR103632 are caused by a bug in REE where it generates incorrect code. It's trying to eliminate the following zero extension (insn 54 90 102 2 (set (reg:V4SI 33 v1) (zero_extend:V4SI (reg/v:V4HI 40 v8))) (nil)) by folding it in the definition of `v8`: (insn 2 5 104 2 (set (reg/v:V4HI 40 v8) (reg:V4HI 32 v0 [156])) (nil)) which is fine, except that `v8` is also used by the extracts, e.g.: (insn 11 10 12 2 (set (reg:SI 1 x1) (zero_extend:SI (vec_select:HI (reg/v:V4HI 40 v8) (parallel [ (const_int 3) ])))) (nil)) REE replaces insn 2 by folding insn 54 and placing it at the definition site of insn 2, so before insn 11. Trying to eliminate extension: (insn 54 90 102 2 (set (reg:V4SI 33 v1) (zero_extend:V4SI (reg/v:V4HI 40 v8))) (nil)) Tentatively merged extension with definition (copy needed): (insn 2 5 104 2 (set (reg:V4SI 33 v1) (zero_extend:V4SI (reg:V4HI 32 v0))) (nil)) to produce (insn 2 5 110 2 (set (reg:V4SI 33 v1) (zero_extend:V4SI (reg:V4HI 32 v0))) (nil)) (insn 110 2 104 2 (set (reg:V4SI 40 v8) (reg:V4SI 33 v1)) (nil)) The new insn 2 using v0 directly is correct, but the insn 110 it creates is wrong, `v8` should still be V4HI. or it also needs to eliminate the zero extension from the extracts, so instead of (insn 11 10 12 2 (set (reg:SI 1 x1) (zero_extend:SI (vec_select:HI (reg/v:V4HI 40 v8) (parallel [ (const_int 3) ])))) (nil)) it should be (insn 11 10 12 2 (set (reg:SI 1 x1) (vec_select:SI (reg/v:V4SI 40 v8) (parallel [ (const_int 3) ]))) (nil)) without doing so the indices have been remapped in the extension and so we extract the wrong elements At any other optimization level but -Os ree seems to abort so this doesn't trigger: Trying to eliminate extension: (insn 54 90 101 2 (set (reg:V4SI 32 v0) (zero_extend:V4SI (reg/v:V4HI 40 v8))) (nil)) Elimination opportunities = 2 realized = 0 purely due to the ordering of instructions. REE doesn't check uses of `v8` because it assumes that with a zero extended value, you still have access to the lower bits by using the the bottom part of the register. This is true for scalar but not for vector. This would have been fine as well if REE had eliminated the zero_extend on insn 11 and the rest but it doesn't do so since REE can only handle cases where the SRC value are REG_P. It does try to do this in add_removable_extension: 1160 /* For vector mode extensions, ensure that all uses of the 1161 XEXP (src, 0) register are in insn or debug insns, as unlike 1162 integral extensions lowpart subreg of the sign/zero extended 1163 register are not equal to the original register, so we have 1164 to change all uses or none and the current code isn't able 1165 to change them all at once in one transaction. */ However this code doesn't trigger for the example because REE doesn't check the uses if the defining instruction doesn't feed into another extension.. Which is bogus. For vectors it should always check all usages. r12-2288-g8695bf78dad1a42636775843ca832a2f4dba4da3 simply exposed this as it now lowers VEC_SELECT 0 into the RTL canonical form subreg 0 which causes REE to run more often. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR rtl-optimization/103350 * ree.c (add_removable_extension): Don't stop at first definition but inspect all. gcc/testsuite/ChangeLog: PR rtl-optimization/103350 * gcc.target/aarch64/pr103350-1.c: New test. * gcc.target/aarch64/pr103350-2.c: New test. --- inline copy of patch -- diff --git a/gcc/ree.c b/gcc/ree.c index e31ca2fa1a8073c09b054602c2fa19cfe0cb23c4..13debe8a4af1e8abe666d88b6694163172894030 100644 diff --git a/gcc/ree.c b/gcc/ree.c index e31ca2fa1a8073c09b054602c2fa19cfe0cb23c4..13debe8a4af1e8abe666d88b6694163172894030 100644 --- a/gcc/ree.c +++ b/gcc/ree.c @@ -1165,31 +1165,28 @@ add_removable_extension (const_rtx expr, rtx_insn *insn, to change them all at once in one transaction. */ else if (VECTOR_MODE_P (GET_MODE (XEXP (src, 0)))) { - if (idx == 0) - { - struct df_link *ref_chain, *ref_link; + struct df_link *ref_chain, *ref_link; - ref_chain = DF_REF_CHAIN (def->ref); - for (ref_link = ref_chain; ref_link; ref_link = ref_link->next) + ref_chain = DF_REF_CHAIN (def->ref); + for (ref_link = ref_chain; ref_link; ref_link = ref_link->next) + { + if (ref_link->ref == NULL + || DF_REF_INSN_INFO (ref_link->ref) == NULL) { - if (ref_link->ref == NULL - || DF_REF_INSN_INFO (ref_link->ref) == NULL) - { - idx = -1U; - break; - } - rtx_insn *use_insn = DF_REF_INSN (ref_link->ref); - if (use_insn != insn && !DEBUG_INSN_P (use_insn)) - { - idx = -1U; - break; - } + idx = -1U; + break; + } + rtx_insn *use_insn = DF_REF_INSN (ref_link->ref); + if (use_insn != insn && !DEBUG_INSN_P (use_insn)) + { + idx = -1U; + break; } - if (idx == -1U) - def_map[INSN_UID (DF_REF_INSN (def->ref))] = idx; } + if (idx == -1U) { + def_map[INSN_UID (DF_REF_INSN (def->ref))] = idx; if (dump_file) { fprintf (dump_file, "Cannot eliminate extension:\n"); diff --git a/gcc/testsuite/gcc.target/aarch64/pr103350-1.c b/gcc/testsuite/gcc.target/aarch64/pr103350-1.c new file mode 100644 index 0000000000000000000000000000000000000000..61c796dc6e8e3733a9446c89189135b83ecb4f3e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr103350-1.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-additional-options "-Os -fno-tree-ter -save-temps -fdump-rtl-ree-all -free -std=c99 -w" } */ + +typedef unsigned char u8; +typedef unsigned char __attribute__((__vector_size__ (8))) v64u8; +typedef unsigned char __attribute__((__vector_size__ (16))) v128u8; +typedef unsigned char __attribute__((__vector_size__ (32))) v256u8; +typedef unsigned short __attribute__((__vector_size__ (8))) v64u16; +typedef unsigned int __attribute__((__vector_size__ (16))) v128u32; +typedef unsigned long long u64; +typedef unsigned __int128 u128; + +v64u16 foo0_v32u16_0 = { 4, 5, 6, 7 }; +u64 foo0_u64_0 = 0x30; + +__attribute__((__noipa__)) +v64u8 foo0 (v64u16 v64u16_0, u128 u128_0) +{ + /* 03 00 05 00 03 00 02 00 ... */ + v256u8 v256u16_1 = (v256u8)__builtin_shufflevector (v64u16_0, foo0_v32u16_0, + 3, 5, 3, 2, 3, 5, 1, 0, + 3, 5, 3, 2, 2, 0, 2, 0); + /* 00 00 00 00 01 00 00 00 ... */ + v128u8 v128u8_1 = (v128u8) __builtin_convertvector (v64u16_0, v128u32); + /* 10 */ + u8 u8_1 = foo0_u64_0 % u128_0; + /* 03 00 05 00 04 00 02 00 ... */ + v128u8 v128u8_r = ((union {v256u8 a; v128u8 b[2];}) v256u16_1).b[0] + v128u8_1; + /* 00 00 01 00 02 00 03 00 */ + v64u8 v64u8_0 = (v64u8)v64u16_0; + /* 03 00 06 00 06 00 05 00 */ + v64u8 v64u8_r = ((union {v128u8 a; v64u8 b[2];}) v128u8_r).b[0] + v64u8_0; + /* 13 10 16 10 16 10 15 10 */ + return v64u8_r + u8_1; +} + +int +main (void) +{ + v64u8 x = foo0 ((v64u16){ 0, 1, 2, 3 }, 0x20); + v64u8 exp = { 0x13, 0x10, 0x16, 0x10, 0x16, 0x10, 0x15, 0x10 }; + for (unsigned i = 0; i < sizeof(x); i++) + if (x[i] != exp[i]) + __builtin_abort(); + return 0; +} + +/* { dg-final { scan-rtl-dump {because some vector uses aren't extension} ree } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/pr103350-2.c b/gcc/testsuite/gcc.target/aarch64/pr103350-2.c new file mode 100644 index 0000000000000000000000000000000000000000..2696212710b9da1c065cd26d26dd9f09719cf9e9 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr103350-2.c @@ -0,0 +1,53 @@ +/* { dg-do run } */ +/* { dg-additional-options "-O2 -save-temps -fdump-rtl-ree-all -free -std=c99 -w" } */ + +typedef unsigned char __attribute__((__vector_size__ (8))) v64u8; +typedef unsigned char __attribute__((__vector_size__ (16))) v128u8; +typedef unsigned short __attribute__((__vector_size__ (8))) v64u16; +typedef unsigned short __attribute__((__vector_size__ (64))) v512u16; +typedef unsigned int __attribute__((__vector_size__ (16))) v128u32; +typedef unsigned long long u64; +typedef unsigned long long __attribute__((__vector_size__ (8))) v64u64; +typedef unsigned long long __attribute__((__vector_size__ (16))) v128u64; +typedef unsigned __int128 u128; +typedef unsigned __int128 __attribute__((__vector_size__ (64))) v512u128; +v512u16 foo0_v512u16_0; +u64 foo0_u64_0; +u64 foo0_u16_0; + +void +foo0 (v64u16 v64u16_0, v64u64 v64u64_0, u128 u128_0, v64u8 * ret) +{ + /* { 0, 4, 0, 0 } */ + v128u32 v128u32_2 = __builtin_convertvector (v64u16_0, v128u32); + /* 0 */ + foo0_u16_0 ^= foo0_u64_0 % u128_0; + /* { 0, ... } */ + foo0_v512u16_0 *= + __builtin_shufflevector (v64u16_0, v64u16_0, 7, 7, 2, 1, 0, 0, 3, 6, 2, 3, + 1, 0, 7, 5, 6, 7, 4, 3, 2, 3, 0, 6, 1, 2, 3, 3, + 6, 7, 6, 2, 4, 3); + /* { 0, 0, 0, 0, 4, 0, ... } */ + v128u8 v128u8_r = (v128u8) ((v512u128) foo0_v512u16_0)[0] + + (v128u8) v128u32_2; + /* { 0, 0, 4, 0, 4, 0, 0, 0 } */ + v64u8 v64u8_r = (v64u8) ((v128u64) v128u8_r)[0] + + (v64u8) v64u16_0 + (v64u8) v64u64_0; + *ret = v64u8_r; +} + +int +main (void) +{ + v64u8 x, exp = (v64u8){ 0, 0, 4, 0, 4, 0, 0, 0 }; + foo0 ((v64u16){0, 4}, (v64u64){}, 5, &x); + /* + for (unsigned i = 0; i < sizeof (x); i++) + __builtin_printf ("%02x", x[i]); + */ + for (unsigned i = 0; i < sizeof (x); i++) + if (x[i] != exp[i]) __builtin_abort(); + return 0; +} + +/* { dg-final { scan-rtl-dump {because some vector uses aren't extension} ree } } */