From patchwork Mon Nov 27 22:40:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1869034 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=eQ2wF+as; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=eQ2wF+as; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SfLCx4xMjz1yRW for ; Tue, 28 Nov 2023 09:41:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 663AA3858298 for ; Mon, 27 Nov 2023 22:41:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2047.outbound.protection.outlook.com [40.107.249.47]) by sourceware.org (Postfix) with ESMTPS id 6AF003858C2D for ; Mon, 27 Nov 2023 22:40:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AF003858C2D 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-Filter: OpenARC Filter v1.0.0 sourceware.org 6AF003858C2D Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.249.47 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701124857; cv=pass; b=di2wSaz+GfYa1j27sd8m4LWMRwdS8LmOKnTgOmO5OMQK2henHgGBn93B+EJNI0WC1s6UeRw4I8ZT60jZF6Xw7q5lIym+IOzOi63s+y9/0cDsrU+9cJyfjnKPqv+uBih3fkXBJkyCXeuQhWOBcRBcdGL+fNP+dexTeUPLwJLHAxc= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701124857; c=relaxed/simple; bh=oHOoDMnNmSZeHhBuoSXqKUUM/Jtt2/ffLQtSoINHIB0=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=Crmky96sapUIAjZoM/2GUUtadoYgQG7XKNOW53zbrlV2ZzPccwjzpi7/DGvugU3yVOFAMHeFbFxFvnkY9mmDZZ7l2eTw3m2w2an1kB2Z6usz2/00KSsjT/0gilGfc7no+PO4bwbERTket4FUE8px9dqU6Tk5SEvxQUtSo0H6shI= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=cPpOyE/AjZ3MbnON7f6oYHEhxMOCc7yPypl+ymcGLwk9ZDJB9+UJinfknSQ/ej2HD8PMRN35WdPtXdRgFwFM83gqd+HcHauGs7ux+hkFXhFI9OG5HC1BXAUy2KCaQmxXiO+6nR/N0LWwrsgtaqpXmKaQhRd/YyP251wMc5h948Utchpn3znPiLxjjFlVxKkwI6FmGZo2t6/BtXMe1vv9VB8p0G5FGfuq1kxfR9lurC6hkkBu87yOFqyo3OXAPy+7p2nowbnECmD4w5wEahNRPTS6jFqGeRLGv0dVvkZi4Vv94n/zCCv36tzaApwhP78EXsK/pvqIYrUAttpXYtyXlw== 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=M36Z9hDNW9dV+SsG/whcEqoRGe/JfcAU36CtVHA45LQ=; b=P3gyonNwv4qwQyVso7mgFkiSZvOyEUGXDwTZYlzA6uBaiwJN5IMEtAv4kpUGay4xwUonEt0FaFTrozvEmHR+R7DAUfaJuJl4BfDLFQ8+Imlc2ZVJxDBez6GS44ERoaDEF4C6qk5gP7dbuL823QHOWhrALsrKFP8NpJeR0oYk0Y5WICZ0xMENitsPLKS2MilbcDadX/j8NHS6JasUe0hQvoImSmzTkYh6n7etPA4VfBb9X+rAURCjikWSR5RnUwKc8GlKNGC86DiLK/01VaqPoqlHp4QYbuKIiC8EGyWcH9KUPtpZDewST8uINtcyvHh2Ich8epXwlfOlfyP2cLNooQ== 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=M36Z9hDNW9dV+SsG/whcEqoRGe/JfcAU36CtVHA45LQ=; b=eQ2wF+aspuD2Z0fopK5q1Uo7a+AfyHx1tWarFvhh1svvx7lJ2SfzTk4bVoWGk8q/1Q0HUVptLtfcU+S/+DpawG6r829y5tC9OlsWTnAwoE0UISET33oflc7aeYlBd3u2vJr32BpZ9uIV8eBKmZF1HaWRUq2+pUtRDon3OzVNlzs= Received: from DU2P251CA0002.EURP251.PROD.OUTLOOK.COM (2603:10a6:10:230::11) by DU0PR08MB7996.eurprd08.prod.outlook.com (2603:10a6:10:3e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Mon, 27 Nov 2023 22:40:49 +0000 Received: from DU6PEPF0000A7DE.eurprd02.prod.outlook.com (2603:10a6:10:230:cafe::e0) by DU2P251CA0002.outlook.office365.com (2603:10a6:10:230::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27 via Frontend Transport; Mon, 27 Nov 2023 22:40:49 +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 DU6PEPF0000A7DE.mail.protection.outlook.com (10.167.8.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.17 via Frontend Transport; Mon, 27 Nov 2023 22:40:49 +0000 Received: ("Tessian outbound 8289ea11ec17:v228"); Mon, 27 Nov 2023 22:40:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b8d458f6d2f9fba6 X-CR-MTA-TID: 64aa7808 Received: from b0f0d9ecf613.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 909F0DF7-3788-45D6-B1EA-F35D78AA2FF0.1; Mon, 27 Nov 2023 22:40:42 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b0f0d9ecf613.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 27 Nov 2023 22:40:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=baxgNBIsgVidcxWbx0S0kFOGPM+GLvb/7ygqi2Q1lyFm+11mW5UyLF0eDb/kg8ouAMvDRzlWeNWq5x3fjSDhpQZvl3bLUOZs/4mHefVgT2DlSyarmyevon0p9YuSrt94SfG9VNmbmOGSQ7X1Llr/ufiF4HlLP/kbHhCezyFh8TlCRVl7kVd28PYfPeWSUWlCedFjO6HvMmk6bIT1Qnw3Evc5EG68+wbLU9L3+TiSwq/tmFSrbFqKNIWoiN+zrveNiTa2G5R1B1A3sKdY/t6UWzeJuv9E0S3PsrOyFQCxiWJGNpA/nWi99FMbOrGQkKD1sgS+8YjFqGdj+afax2KW8A== 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=M36Z9hDNW9dV+SsG/whcEqoRGe/JfcAU36CtVHA45LQ=; b=GSKLgHj0iX2HzKhgdirsK1qh348mlU0sWAvOvKHFvrZR27ngXIMyRqL0ROxthSIlHaJDCgsnlypQ52QUT5gRbEl7rv8/HHAHM/O/V2/4gLNhAN7Z0gYtKEU9UZb6YoSQJMA4yJ4rd5PwZgJ3+3AzdwApONEj+Klwa8wTyy9FNBZu74rcSE3+EO5O/b3BS61qIezC2mZwHbUPKt93gUw5zos1VWNsjz4953Xv2Yp1hVvc8pgyx8yQ5uDupsubPsBDumedcrxcgQ3zuYOYMrmleFYuKaqIgbptCB0OfiDuRAW3hwBnIKivkA67TEwfcshi44HbpdvqMdVg+wltEHmj6Q== 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=M36Z9hDNW9dV+SsG/whcEqoRGe/JfcAU36CtVHA45LQ=; b=eQ2wF+aspuD2Z0fopK5q1Uo7a+AfyHx1tWarFvhh1svvx7lJ2SfzTk4bVoWGk8q/1Q0HUVptLtfcU+S/+DpawG6r829y5tC9OlsWTnAwoE0UISET33oflc7aeYlBd3u2vJr32BpZ9uIV8eBKmZF1HaWRUq2+pUtRDon3OzVNlzs= 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 VI1PR08MB5423.eurprd08.prod.outlook.com (2603:10a6:803:133::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Mon, 27 Nov 2023 22:40:39 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3%6]) with mapi id 15.20.7025.022; Mon, 27 Nov 2023 22:40:39 +0000 Date: Mon, 27 Nov 2023 22:40:37 +0000 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH]middle-end: prevent LIM from hoising vector compares from gconds if target does not support it. Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO3P123CA0029.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:388::19) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|VI1PR08MB5423:EE_|DU6PEPF0000A7DE:EE_|DU0PR08MB7996:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c4c4253-385a-4c35-4467-08dbef99e784 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: 4rqh2jaNNhuBJbBvAN8xMwuvZ+D6li9GRKvXXHX8C53qKYorrtNRZpKQCtA6UoIEWUegXKgzQVNvdcasJ39UgMH4WrTgXMYpdUCEZcoBl19bsc5V2fkGeUTsWfrry46Og+tiFh+JU019r42JbkNIDUljwo32lvldcdjOU8hcWk+BMY3Tknevg4VzdH+33enlAjMuiL4HyFvJlAZi9X4xRGOqlxq7pxCaFOdDzNVGDbYslqZjJREAmwQwl3J6DWABFXIcxz70EloNAM7fPGEAH94oslTiNiRiOj8Xgnv51FCG2ZG+EotiLBJXJbcvGVj9BT2pJI834EaD5jnQk6o5dwsji/Q1RsFSRu7j/YsDWE08LBdHUKwxIAfYISajCNGfWXFppAT0J4hqjrv9Lv97pE47JBsizLwIe8Nfe3FKVMLnMBKuZAU4IpdGv67kzekol45JWjq/3kwduo1Dd9zVCc7C2GIin7sh3xFf1wErVIyEdsgUNtWdqqGXg5Y+IRPYv+k9JAmeAFaqxF1l5aJk5al4n6v1lijxN5VP7Y1p5XWKiuvL9g6H+axeFZS0SvN/GJdmPs+SC8kxHzIAV7GuaRPvddmO8/tcedWVfdYGpHw9n5XETTHJiIIO1CZPuxUIb9XfRUYpgXQkPzA/bKajow== 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:(13230031)(39850400004)(376002)(366004)(396003)(136003)(346002)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(83380400001)(38100700002)(33964004)(8936002)(4743002)(6486002)(4326008)(6506007)(6512007)(8676002)(44144004)(66476007)(66556008)(66946007)(316002)(6916009)(5660300002)(235185007)(86362001)(44832011)(478600001)(2906002)(41300700001)(36756003)(26005)(2616005)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5423 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: DU6PEPF0000A7DE.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 19f6b392-08cc-4302-efac-08dbef99e15a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lYF3JDDi/i24KApHM7kSo60aGZjf8iISPsxNQck8YT91SX1sVUXZ4H7BeTXbvEBET2C7CNj12//kj7G7ViCqrLWCQueJeZ6TZqTEn33lohzSYFxzBldngurj2l5OtroX25Pi2Qeuw8cg8OPEr1M7C2tfGXoboPZ0gX9CUouNqaP7E9g4ai0oo78f+WRxXvWv6PCvPgJHni9VSj1KWy1RM+QiKyqtDq4nIuGtzLafJ207ajMXtwjEvfB6SzRUiSnv2+GOy13rE2Z4jL6NpwcE6taSirpbVNAxoI+QvR2wDZSzhvzSuP5sAe2chHD2Y+CXSl7niD3QmIUfUYh/awOzNIedP2IKFqzlubx+3MgW9hX6gNohDkEKt4SVsX1JDb4wPQUdgg97kYGaTdy60vwtcQtyZR6j0oDf4MK4jgMAhXVkAE9B4tl4Jlgc9zuY22e6iYHdoEjd3Kwsoaw2RBPN1HeBSSDdLbbdPBsgFPQBnakcAENf4AID4ATPLNHIIPjj3+typUk4OdUsjWcObtysWMBZd1hiUYoSiP1aYCuKA2DXDzrRcDQlKJsUbE6t7K84t+74lNLEjtA2OF5V34KRy5p/Uz/y1IxQIATtU6YqkkCRdfhUQepqoLDNcJIFye7wJKtDMdMDiFdP/aGX8CMuMD+vf7MND5v7rEpX7HQ6lmp0JLVP34cistKYuuYMohFFLIU03Z3FUaXnLmkjuO8ouHEy3RqULkHytBrHNCgIbFGS4lWmzvFXas2jhiEB3Z8M02lU+B2sDXdN2wFWdQDSvUnhTVB1Fe7Z2cv13vojP3Q= 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:(13230031)(4636009)(376002)(396003)(346002)(39860400002)(136003)(230922051799003)(186009)(451199024)(64100799003)(82310400011)(1800799012)(40470700004)(36840700001)(46966006)(40480700001)(26005)(2616005)(44144004)(6486002)(33964004)(107886003)(478600001)(6506007)(6512007)(36860700001)(81166007)(356005)(36756003)(82740400003)(86362001)(235185007)(5660300002)(44832011)(2906002)(70206006)(70586007)(47076005)(336012)(83380400001)(4743002)(4326008)(41300700001)(40460700003)(8936002)(6916009)(316002)(8676002)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Nov 2023 22:40:49.6297 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c4c4253-385a-4c35-4467-08dbef99e784 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: DU6PEPF0000A7DE.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7996 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi All, LIM notices that in some cases the condition and the results are loop invariant and tries to move them out of the loop. While the resulting code is operationally sound, moving the compare out of the gcond results in generating code that no longer branches, so cbranch is no longer applicable. As such I now add code to check during this motion to see if the target supports flag setting vector comparison as general operation. I have tried writing a GIMPLE testcase for this but the gimple FE seems to be having some trouble with the vector types. It seems to fail parsing. The early break code testsuite however has a test for this (vect-early-break_67.c). Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: * tree-ssa-loop-im.cc (determine_max_movement): Import insn-codes.h and optabs-tree.h and check for vector compare motion out of gcond. --- inline copy of patch -- diff --git a/gcc/tree-ssa-loop-im.cc b/gcc/tree-ssa-loop-im.cc index 396963b6754c7671e2e5404302a69129918555e2..2ebf6d6548c4858fd5a8b4f9ab6f332f3fe8f6cd 100644 --- diff --git a/gcc/tree-ssa-loop-im.cc b/gcc/tree-ssa-loop-im.cc index 396963b6754c7671e2e5404302a69129918555e2..2ebf6d6548c4858fd5a8b4f9ab6f332f3fe8f6cd 100644 --- a/gcc/tree-ssa-loop-im.cc +++ b/gcc/tree-ssa-loop-im.cc @@ -48,6 +48,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-dfa.h" #include "tree-ssa.h" #include "dbgcnt.h" +#include "insn-codes.h" +#include "optabs-tree.h" /* TODO: Support for predicated code motion. I.e. @@ -852,6 +854,17 @@ determine_max_movement (gimple *stmt, bool must_preserve_exec) if (!extract_true_false_args_from_phi (dom, phi, NULL, NULL)) return false; + /* Check if one of the depedent statement is a vector compare whether + the target supports it, otherwise it's invalid to hoist it out of + the gcond it belonged to. */ + if (VECTOR_TYPE_P (TREE_TYPE (gimple_cond_lhs (cond)))) + { + tree type = TREE_TYPE (gimple_cond_lhs (cond)); + auto code = gimple_cond_code (cond); + if (!target_supports_op_p (type, code, optab_vector)) + return false; + } + /* Fold in dependencies and cost of the condition. */ FOR_EACH_SSA_TREE_OPERAND (val, cond, iter, SSA_OP_USE) { --- a/gcc/tree-ssa-loop-im.cc +++ b/gcc/tree-ssa-loop-im.cc @@ -48,6 +48,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-dfa.h" #include "tree-ssa.h" #include "dbgcnt.h" +#include "insn-codes.h" +#include "optabs-tree.h" /* TODO: Support for predicated code motion. I.e. @@ -852,6 +854,17 @@ determine_max_movement (gimple *stmt, bool must_preserve_exec) if (!extract_true_false_args_from_phi (dom, phi, NULL, NULL)) return false; + /* Check if one of the depedent statement is a vector compare whether + the target supports it, otherwise it's invalid to hoist it out of + the gcond it belonged to. */ + if (VECTOR_TYPE_P (TREE_TYPE (gimple_cond_lhs (cond)))) + { + tree type = TREE_TYPE (gimple_cond_lhs (cond)); + auto code = gimple_cond_code (cond); + if (!target_supports_op_p (type, code, optab_vector)) + return false; + } + /* Fold in dependencies and cost of the condition. */ FOR_EACH_SSA_TREE_OPERAND (val, cond, iter, SSA_OP_USE) {