From patchwork Fri Nov 11 14:44:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 60421 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 D0C7F3858C5E for ; Fri, 11 Nov 2022 14:47:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0C7F3858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668178030; bh=fTv1v2bsKW0lrIBAmGYDDq0bCBmTt4kVRsKiUKh+11s=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=G1oTfoy0mCKYSRLe1sNnInfiSdEBDIdOgkCvVMR+z3ng4KzvhclYkR5/WrvB6tzPY zNfe3Lcphk5vIqp3yxTKfdlmarSmUZ4x+6p5r8yqiNY2BVH2aMhm9l1KWTG/ISeuaV OZcCIw3uivFmk3sZ1Rkhn1BwjmHuf59b5VrB9+z0= 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-eopbgr60048.outbound.protection.outlook.com [40.107.6.48]) by sourceware.org (Postfix) with ESMTPS id B0F713858D20 for ; Fri, 11 Nov 2022 14:46:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B0F713858D20 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=PDeyQKeE2SOxyK5Vb2+k24SkPhN247YhzpH7SnPbP8XGiTYX7VWh0wCsE3ixuGRBuUoZJfHsNeBbyQW4ha2vesrB6WgCPB++bgFKr+E4KqjKlMqjkTIcdEhSQoUkdAGqB458Nr4VmD7KR/7fWa+ronHeiuEX6OVlyMDFxNq/HOx7DND8CI7NyI/Cv7za797KKvs7SeAm1l4DCOW0wOJ4zbGCCh9ThichdTDuPXd/4tO+HYaqW1ROUo2fYR6o1c3dCXL5zYU0uEcBmlX9O96t5J/LA2o8iTDc4NRf4KFx3WF/6AyvlB2xqEvMWdynBUe86sHEW8OutN/+rz9ds9FJ+g== 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=fTv1v2bsKW0lrIBAmGYDDq0bCBmTt4kVRsKiUKh+11s=; b=E4bgm6L+ZC3FdM7yfmmdQAjLzjd0zFReU66EJnvId3E8fjxHkooQFzfqhidNRHuL7jg6fImcWCWwg2DRhBNSuO+9GOuCYwCtkonwRiAeskrvyHNgd+84yq9L1uufTy4scvAcBS/P/rMntF+V/38zNue/yX5OndUXakzR99GGbqdm2ZJAfs9Fvoma/3O426cE1O2FmRZBnBgh1jjtnZnx66e9Pggx3Yzcq9Iz9yLqZZwN6Q1CEOIe00dxbjE/RYiHokajhahVzOnO0TEJ/sAa+PtoNrcVDRR0NTHvLiY7D+CIjcuqVebB8ODJaT6GYp1DycogL8Te5lO44ie5RrSXrg== 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 DUZPR01CA0052.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::8) by DU0PR08MB8496.eurprd08.prod.outlook.com (2603:10a6:10:403::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11; Fri, 11 Nov 2022 14:46:29 +0000 Received: from DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::30) by DUZPR01CA0052.outlook.office365.com (2603:10a6:10:469::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.14 via Frontend Transport; Fri, 11 Nov 2022 14:46:29 +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 DBAEUR03FT052.mail.protection.outlook.com (100.127.142.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Fri, 11 Nov 2022 14:46:29 +0000 Received: ("Tessian outbound aeae1c7b66fd:v130"); Fri, 11 Nov 2022 14:46:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0e14822c11fcbdfc X-CR-MTA-TID: 64aa7808 Received: from a727ef84ecba.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3B444706-501A-428C-8CE5-A1C6FB0D7B8B.1; Fri, 11 Nov 2022 14:45:08 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a727ef84ecba.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 11 Nov 2022 14:45:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JK/1/zIse86mRYrd4lYdWk6wismDsAbRrobDpeTOSLOWjEefKKtJv1hC6xoyUcm/LZB87mnQwNRW/SfWMn9LgZOdHyjGISxG5GWt0PO4/p9U4BCxwv8+Tk9nof7G8uKFv+rxZ2geHUYNSZXF34dVhwNg8VE/9PDrEjuZ/A1IyxbJ3Nayul0SG3Sfcbm3LHCwMGpD3Ku3H8ONlfKFXkb/mb8zTmowCpy+G4Kl8A60IvmS6l0EToJF56AVvbNps6OY/4Srp03aJG+1M5gVyjqoCCQihxsY7Uw1GM59EYx6fL7bF5mQjIHJBHZzZkon2FtFw5462JNWKcs8dTlz4NrpPA== 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=fTv1v2bsKW0lrIBAmGYDDq0bCBmTt4kVRsKiUKh+11s=; b=ShkjuvA967FT17DL5LrfuJCMvqyEOfFJWLB/MQGIIPc06B7wWPqDPnBWddkI2Hi6SrbXnA5CNYJOu9orWFcJOBWpqCF2iokkyUyw9oy50Nfm4Cm7p/A4IikMra3Ft0EFzed/8Od1z6AJ2PgufmvmPzrQcDGg6cnd4020xa7gn/SqS1A/plyzgO6OfMmuSaXu/IGc9CoUw7bUHvDxp9ch+qIH9V3Y60r936UrFBgna5/RZtuxyCaTuEb8bj3mmK12wJuz3NLL71WHP79VvNgHygBUYiPn+4ci3yoUdfdRxGMHwGdQrs0U4GQHTg+5BAilsMTRltiMPUBDHH+wEcptgQ== 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 PA4PR08MB5936.eurprd08.prod.outlook.com (2603:10a6:102:f1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 11 Nov 2022 14:45:06 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bd2a:aff9:b1a0:2fc7]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::bd2a:aff9:b1a0:2fc7%4]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 14:45:06 +0000 Date: Fri, 11 Nov 2022 14:44:55 +0000 To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, hubicka@ucw.cz, ubizjak@gmail.com, kirill.yukhin@gmail.com, hongtao.liu@intel.com Subject: [PATCH][i386]: Update ix86_can_change_mode_class target hook to accept QImode conversions Message-ID: Content-Disposition: inline X-ClientProxiedBy: SN1PR12CA0049.namprd12.prod.outlook.com (2603:10b6:802:20::20) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|PA4PR08MB5936:EE_|DBAEUR03FT052:EE_|DU0PR08MB8496:EE_ X-MS-Office365-Filtering-Correlation-Id: 48a9eee7-1028-4e81-b404-08dac3f38498 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: y0HRBJTm5BCR42s9D6XOKf+U9LQQMqMbsp8i1ooe0eFKOoYFrkI8O5LCRGrfBwp7QNERsdfffWg9ViXMXE0yn8R9Q56e8oOfrohngEs1/J6yzA3+FQkGw7YpirDJJKFgHRyt4qoLHSNZ3HYD8cUm8kq3hMpFjM8LXkvGYcLqZV4FFvBWXqwJhgVLcPBIB7vh18cChZyzmoZNcsrvf2dyC+UZNTDl28Wyrie76te758j/K5r5+vdHTDFHX33lqogj6OLBce3ji8q7AtUrr5wPjAt9m1jtqYj3layZyZE56aKTNC2Iqf2k389LAnTXiftVkpyYFWt+fzkCHPwLN4vUPpp0XwAwO3wS/LQ6KYEFDl17lIfQUTvYqopNHjRi+ehkZ2vfn+DIX3pghrCVAsZaYNokj8z+d5TWCoPjv1Yy9zUdHkafj6Fr3XiuytgKa3/gK9cQDYYf4OGHKG/K8j8eq5ji61Ww0H7Wngq/jN1pIMzN5NYK77sEjavnflvZkLAEKtMFw6vUw2sZLtSVETBG+KCFzIhblq2cHRZXsFt30XCDP2RgfHn1HEGsngjTQyj3ixVUv2D2M1Z/ZF6BYUVQCaeyHbUekM9j53Q7CqBmYIJgjxCz51m+yBlKhyajE3fxAfPxxkHD8k6JwM+OdI0mLfJ7XApHOTwcSxH87IGwqxrj77y93qbLOZlqLkSLes/qjjbgT5ealGXSJyTl+3h8cn4hdpr+VAX1BcNDI5hm/KwqkDIOCp4LsgjhClXVAkbCT29WHpVHYbAHJrP18Y1LACL0tOGZbYvm+CmeplkQ4qQ= 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)(396003)(366004)(136003)(376002)(39860400002)(346002)(451199015)(6486002)(38100700002)(478600001)(66899015)(6666004)(6916009)(8936002)(6506007)(33964004)(316002)(36756003)(66556008)(66476007)(86362001)(66946007)(6512007)(41300700001)(8676002)(4326008)(26005)(44144004)(15650500001)(83380400001)(2616005)(44832011)(2906002)(186003)(5660300002)(235185007)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB5936 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: DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7aebcb3c-0a54-45f2-e178-08dac3f3519b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WwdLRVYhOAFMkJXFcA6lb4sDa58RHrF7bvjBEZL6LqxMFNQwr0J1EbD11qELirTppv0d+xkgBTn/ejzoSFO8ECXSj0xp6gpBEXqq9cSJvl3EfK5Go5jQVjyuPvWm6Drj/zL5DOqBdK66l5v/anC/BvTnPVcgXAnFhqOgIR/vmeKxqnYBRsX6mA4aFJ01XDUXMnopHXkxAFtF/wjz5lw5pdPk3sQs9Vvy60DYw5yTJKyt6nL+pZRN8QzUG/Frjw4aKxdutlorIqBFseSRrKdnI0E4vbOXqCVxHr1Dz5NUbgfDlcMN8fCbn1XFseu4G2JY4wX3VhlhFrC3BVCSuY9/+qIIhXKv3ochM2t7XjQ2ZW+qwQ3ueRCED0UH+vAb7MN7wlVk+eb7Xl1rOiuFb/PIHlKQexMbBrZikEG9A60N37jYSv9vI5ZOADJDo1kwAkmgZ9JgYvrTS7EgnK8O/S28HLbfftbY/ee7FJLwVH81ogj9oGg2OPQ2X46kKMODAAC1Z8pJqQ5I7XclcCNsatrYHomE/KtDpW694i7Uv22306zONghfsI648ijUekaltdW/GTdnVjRlh/DnIkxMfJwZHP17trkbPxFJeAtXMipN9FxN2wT4RTNzMeaS3td0Upm3qHb/5GdMtIENrAOuI6Po5KkjQDmDn+e6gjzjlxCmtyNFahRUKuPBESpthNtUnFDHM5rC8pwKDZBPiYmRxYIJrNJfLkZRZoyIijAVGfCvA9ylYHzDPbsiEL+pgM9a/iq1nxLixrGHeIPNuHjrVduFc36skEGJoFTnEAswV+jxT5MUsRYK/uoWlfj2rP8dmC4RFsQpzubVYk3d0OPKig49Vg== 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)(136003)(39860400002)(376002)(346002)(396003)(451199015)(40470700004)(36840700001)(46966006)(36756003)(6666004)(26005)(47076005)(107886003)(186003)(86362001)(6512007)(44144004)(6916009)(15650500001)(40480700001)(336012)(33964004)(82740400003)(40460700003)(36860700001)(356005)(81166007)(2616005)(5660300002)(8936002)(44832011)(235185007)(70586007)(83380400001)(70206006)(4326008)(8676002)(82310400005)(316002)(41300700001)(6506007)(2906002)(6486002)(66899015)(478600001)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 14:46:29.5415 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48a9eee7-1028-4e81-b404-08dac3f38498 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: DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8496 X-Spam-Status: No, score=-12.6 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, 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-Patchwork-Original-From: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi All, The current i386 implementation of the TARGET_CAN_CHANGE_MODE_CLASS is currently not useful before re-alloc. In particular before regalloc optimization passes query the hook using ALL_REGS, but because of the if (MAYBE_FLOAT_CLASS_P (regclass)) return false; The hook returns false for all modes, even integer ones because ALL_REGS overlaps with floating point regs. The vector permute fallback cases used to unconditionally convert vector integer permutes to vector QImode ones as a fallback plan. This is incorrect and can result in incorrect code if the target doesn't support this conversion. To fix this some more checks were added, however that ended up introducing ICEs in the i386 backend because e.g. the hook would reject conversions between modes like V2TImode and V32QImode. My understanding is that for x87 we don't want to allow floating point conversions, but integers are fine. So I have modified the check such that it also checks the modes, not just the register class groups. The second part of the code is needed because now that integer modes aren't uniformly rejected the i386 backend trigger further optimizations. However the backend lacks instructions to deal with canonical RTL representations of certain instructions. for instance the back-end seems to prefer vec_select 0 instead of subregs. So to prevent the canonicalization I reject integer modes when the sizes of to and from don't match and when we would have exited with false previously. This fixes all the ICEs and codegen regressions, but perhaps an x86 maintainer should take a deeper look at this hook implementation. Bootstrapped Regtested on x86_64-pc-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: * config/i386/i386.cc (ix86_can_change_mode_class): Update the target hook. --- inline copy of patch -- diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index c4d0e36e9c0a2256f5dde1f4dc021c0328aa0cba..477dd007ea80272680751b61e35cc3eec79b66c3 100644 --- diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index c4d0e36e9c0a2256f5dde1f4dc021c0328aa0cba..477dd007ea80272680751b61e35cc3eec79b66c3 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -19682,7 +19682,15 @@ ix86_can_change_mode_class (machine_mode from, machine_mode to, /* x87 registers can't do subreg at all, as all values are reformatted to extended precision. */ - if (MAYBE_FLOAT_CLASS_P (regclass)) + if (MAYBE_FLOAT_CLASS_P (regclass) + && VALID_FP_MODE_P (from) + && VALID_FP_MODE_P (to)) + return false; + + /* Reject integer modes if the sizes aren't the same. It would have + normally exited above. */ + if (MAYBE_FLOAT_CLASS_P (regclass) + && GET_MODE_SIZE (from) != GET_MODE_SIZE (to)) return false; if (MAYBE_SSE_CLASS_P (regclass) || MAYBE_MMX_CLASS_P (regclass)) --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -19682,7 +19682,15 @@ ix86_can_change_mode_class (machine_mode from, machine_mode to, /* x87 registers can't do subreg at all, as all values are reformatted to extended precision. */ - if (MAYBE_FLOAT_CLASS_P (regclass)) + if (MAYBE_FLOAT_CLASS_P (regclass) + && VALID_FP_MODE_P (from) + && VALID_FP_MODE_P (to)) + return false; + + /* Reject integer modes if the sizes aren't the same. It would have + normally exited above. */ + if (MAYBE_FLOAT_CLASS_P (regclass) + && GET_MODE_SIZE (from) != GET_MODE_SIZE (to)) return false; if (MAYBE_SSE_CLASS_P (regclass) || MAYBE_MMX_CLASS_P (regclass))