From patchwork Mon Mar 5 16:51:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 881570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-474288-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JavnDVsc"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zw5Xv2SKlz9sZh for ; Tue, 6 Mar 2018 03:51:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=uFItYS6AkLcPN+83B2yDOiutDa78TJE3nXQtaWF+ya/RTdzjuF 9sKHJbqxH307SFK4faSIg86vdvvVlkHTBua8ONdNmz2Jq576LYt0odaYOvxr1sTz g8DfjEyAC5qMwppy/57q/JJZHd3Pb0YfOAwq7rLkKI2W6uwwy1NlOnGWk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=QcJ1kvN0pVYeNyYs5WKTFCfnFSc=; b=JavnDVscrHj4RV1foWs7 zhaNFHk7E055G+ZLbqfwIfQzvPP42Je5BAB9z7HN7RyQcjBEovhf7pbCmEEeDnO7 lcSveNWQD26K36pzaOWE+mIPkh695qEuTAc+JksdFjtRigbhWrpcY5XWKlMAmB2t z+7rlAUDvdeU+OdjdzhYC2Q= Received: (qmail 95593 invoked by alias); 5 Mar 2018 16:51:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 95582 invoked by uid 89); 5 Mar 2018 16:51:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Doing X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0081.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Mar 2018 16:51:48 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tamar.Christina@arm.com; Received: from arm.com (217.140.96.140) by AM5PR0802MB2499.eurprd08.prod.outlook.com (2603:10a6:203:a0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Mon, 5 Mar 2018 16:51:44 +0000 Date: Mon, 5 Mar 2018 16:51:41 +0000 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, Ramana.Radhakrishnan@arm.com, Richard.Earnshaw@arm.com, nickc@redhat.com, Kyrylo.Tkachov@arm.com Subject: [PATCH][GCC][ARM] Fix can_change_mode_class for big-endian Message-ID: <20180305165139.GA27394@arm.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-ClientProxiedBy: VI1PR0602CA0003.eurprd06.prod.outlook.com (2603:10a6:800:bc::13) To AM5PR0802MB2499.eurprd08.prod.outlook.com (2603:10a6:203:a0::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e56a1964-9256-46af-efbe-08d582b9611f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(49563074)(7193020); SRVR:AM5PR0802MB2499; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2499; 3:bpchRlPsrEaiqaWnxZRwIRtp1752CnUXtKe6ZVtrvXuQzXkK5q7Iuxa6MowwX9yFloE8Ds1hPBzuzR2lDItpN1mQ2ACUwwapqzj4ETU+d5YZqJIXdwOv6nxDuTC9/L2HqLuBPwm+PtASvtvLh29VKTnjZvcKeIUWAosF9FiFM1HNJlVPdSPNvoKoR6lDkTNKaVka8CQhdWnLna3ziUrJOVDdsJUtFNgns1y1hO2A6ZdWnwI/PcSurp/8A8b4NB7U; 25:2qjPx4I/7qW+bA014/KfJc/PGfp/M0ymbFwlYz5LtPhXE5KV/+kFYz4D3VF1j5Q4Uo4mZDkfOo0QPtH+mfv9Kjqkn3tgCEYHufID1x8JpHP6Fd2aPBmdrHf3vA9bwhtYvxs9SYZHrVXHOb8h2W356RDMMKVWEcohufkAb4cP9RdlFYI7IwRp/ERZ4NHhrIasGAzDU+4eMdnYh5Wvi6Qa8Ngo48u9Unxeyha5mJGd43atb5tGNnxN+qMHBB3BHgbhA3ag3TynllXs/WOBnW4GxB4wxsHXrKgD7QlqWFe/AkLZVssm74VRw2Gvn0Jqo4zpx6OXF+iHyoYF/d1AcjBNMQ==; 31:u2UHGxsmtphCeufgo7VCpmPWTWY/0xg8JG/ek8rBZw5O1Id5fPsQkKt4iN7bSy/wYZWp9u/7uzMIk/NQdmZrrwy0ZqTZK4IbNZJ3E0Jgh8JKzAfcIffOcDYziSxsXjE94NUjTFdOM1hYOkbZ5YpG23PTf+JGYZluuObqQ0tGtVSUi1sZ3ag1N9ifP7JmMAsffjIhrQC9rxAgjSxET34pkPFduo671h4nLVPaKCSS08I= X-MS-TrafficTypeDiagnostic: AM5PR0802MB2499: X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2499; 20:rFlrdMNVAn7D1U4olSBaeCwaW5Q+Wfg9ELYH9O7A92/oGPByMsZ2vk5Za9zW/sPd75lNIIjzjxmBqaSY16qbsBvGmS0FtrC7toMtU72uebNWFMlrYFgbh/EIn7hJkc+e3Kp8X5RDMqeDFkkD3lX+gjB4pkTx6plu0zIsVzM4hXg=; 4:NCk/OSL25ZRLu/lOfaGSTKNlT1G6ssXhgbfnUbYvWIfLmiJQFLVZ3ZJiR3QQ5i6R5OCax/xlvWEB89bXWvuYlJQ3Tv4PfquHyPxRfZlPi3YOjVm0feO2OdXLaFGUb+6B0mZzw7bbtNAYdDGo9OuMw1YCVxoux1aB9rgM9uLXE1OwY/RHZfqYHpW+oujsvQ6ktGruOzL3af0CCNjQejnSNEcvnW7yAv29l12EQYNeAgrQ7RrTeoZQ7HObHQF+q0vbunEh41OnHC8zrLW2GhLPe/O7mhMHhmw8G2Xe1rCPAbp8Uzw6sgpnH2jjwgQhYVm9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(102415395)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231220)(944501244)(52105095)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:AM5PR0802MB2499; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2499; X-Forefront-PRVS: 06022AA85F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(396003)(346002)(39860400002)(39380400002)(199004)(189003)(377424004)(53754006)(8936002)(72206003)(186003)(6666003)(16586007)(568964002)(86362001)(2361001)(1857600001)(106356001)(97736004)(16526019)(25786009)(58126008)(4326008)(105586002)(53936002)(2906002)(26005)(59450400001)(33964004)(44144004)(386003)(2351001)(6916009)(33656002)(5660300001)(84326002)(52116002)(4610100001)(7696005)(36756003)(1076002)(8676002)(6116002)(2476003)(316002)(21086003)(3846002)(68736007)(305945005)(7736002)(66066001)(55016002)(5890100001)(81156014)(478600001)(81166006)(18370500001)(2700100001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2499; H:arm.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2499; 23:x8/PWSbA5THmqCJeT0xeTP1fyM3EoaMxIqb+sB6mMo6OatNVWUmM8/dQhe3CqG7OqWQ/rTOkvT011F1uyOyd+xJip81Gvu6nEg8sTn5gAMq1QIFc/ws5JbqYRkGD0Q68qvB04M96jKu6Iaxfw3kQbt55QHYGuruZMk+dHRQREaHIi/ZZVmNSRPnTzpLbhNfgz5iQDq5zvMkHNWcvDKxHokIdGbKz5rfXV6+Sh2EGnq9SHfX/iWzYEi9+0W0XBUUzsg2bDY86ayTcGtsegAjWIJ4ts78XEWPpk7FlN6Ntx/+eqmKiZonSughmKRk9rH484qKi8psfkNDwtymysg2goO9M5ZHfd0JPQU+zllrq916klgQPyePqP4e/4X6rh9TNFJ5XkO8gEF5rFyU18fpU6imFdDKS+MoNiZuOO+YSDQkT776FyxVqZtCJVSinYtLKsUP8EwzIcspwkp75PE81WrCYrztXdCjd0RC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5p+JydA4nnOgA/63CdtzAcgX1bO2XHu7XdCPfr0 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0802MB2499; 6:Teq4G6mFKS23iZiF/C/eRBdRKA3EZPO5utlLSJu2vMfnp2O3JtWlwNobzIVd4jAsd0ohvy50mJ2ituoWOkX2mcWEgppzORZ9D5ZGJwS4qLRrLceZGVLjTdshd9j02YT+MzyM/2zJf8cO8NMLkMGx/HDklOav8tjda7pUpMDjFOT9vs2buTUPJ7XS/43SS6tOYP03bXG64NHeMfsc4fIYC8L/0hcLItIPkp66L4rHktlm2KXr+rDan/sPQWc8srdcpeya1aZrPmtpeRSJoZNneWC9umX5LEVTZnYntt2mkLSYgXaGF94YMWom4MNPgp4vui9kZfrSSrWgSUmcN08deVz8EIfjceXWXkvdMDmNhBQ=; 5:bkNvo65Mpb/L7yiFwaiGuVIYiCU5u3tvq3QaL8t3w6LWD0KajLw5h4xZth2NukBRpXhQUNO0HdJaQUcKF/nv8Sdwmp1cHGUyqamIlm08kPPG6NgBKjFqoHbbYdAdO7boV/RC11PxhZdU46n6sIr/yqafi2pL3R0KKJh2We8cvlY=; 24:1s6t2sU3MYa0cXQ6ajsWma4JJ3/q7efIWStOYnhvkcXHaBJSJv9bwS9HAf87hVq+lUrl+6Ix8xd4Ru/LJFTk7LhpqZ8Rvx5YXHbW0J9Wemk=; 7:ji/RPHbE/Oij4Lu0djSXpvZ8y5bj+ha/IXZCB8P7xAaD27OBgmWDLN6AA4yjUUccojycnYxhtNIFiqvtX0vmgFAwXTmm9YyYhhtfX9gDja9sSI+EDTeNxqQjUkD2pSApXLRhnKO9US6xS4KZu6AqQIBDPuQ0BOW93zKcX96Brm5waD1Zbmsnr5X6Nvl2hSjdMJ3hyR2IklSZKPw1k7JZQMY+Bs/Ja/fjsZ+LWolD/1sbi8zO4XDPoe5V2UF/FXxs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2018 16:51:44.7524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e56a1964-9256-46af-efbe-08d582b9611f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2499 X-IsSubscribed: yes Hi All, Taking the subreg of a vector mode on big-endian may result in an infinite recursion and eventually a segfault once we run out of stack space. As an example, taking a subreg of V4HF to SImode we end up in the following loop on big-endian: #861 0x00000000008462e9 in operand_subword_force src/gcc/gcc/emit-rtl.c:1787 #862 0x0000000000882a90 in emit_move_multi_word src/gcc/gcc/expr.c:3621 #863 0x000000000087eea1 in emit_move_insn_1 src/gcc/gcc/expr.c:3698 #864 0x000000000087f350 in emit_move_insn src/gcc/gcc/expr.c:3757 #865 0x000000000085e326 in copy_to_reg src/gcc/gcc/explow.c:603 #866 0x00000000008462e9 in operand_subword_force src/gcc/gcc/emit-rtl.c:1787 The reason is that operand_subword_force will always fail. When the value is in a register that can't be accessed as a multi word the code tries to create a new psuedo register and emit the value to it. Eventually you end up in simplify_gen_subreg which calls validate_subreg. validate_subreg will however always fail because of the REG_CAN_CHANGE_MODE_P check. On little endian this check always returns true. On big-endian this check is supposed to prevent values that have a size larger than word size, due to those being stored in VFP registers. However we are only interested in a subreg of the vector mode, so we should be checking the unit size, not the size of the entire mode. Doing this fixes the problem. Regtested on armeb-none-eabi and no regressions. Bootstrapped on arm-none-linux-gnueabihf and no issues. Ok for trunk? and for backport to GCC 7? Thanks, Tamar gcc/ 2018-03-05 Tamar Christina PR target/84711 * config/arm/arm.c (arm_can_change_mode_class): Use GET_MODE_UNIT_SIZE instead of GET_MODE_SIZE when comparing Units. gcc/testsuite/ 2018-03-05 Tamar Christina PR target/84711 * gcc.target/arm/big-endian-subreg.c: New. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 90d62e699bce9594879be2e3016c9b36c7e064c8..703632240822e762a906570964b949c783df56f3 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -31508,8 +31508,8 @@ arm_can_change_mode_class (machine_mode from, machine_mode to, { if (TARGET_BIG_END && !(GET_MODE_SIZE (from) == 16 && GET_MODE_SIZE (to) == 8) - && (GET_MODE_SIZE (from) > UNITS_PER_WORD - || GET_MODE_SIZE (to) > UNITS_PER_WORD) + && (GET_MODE_UNIT_SIZE (from) > UNITS_PER_WORD + || GET_MODE_UNIT_SIZE (to) > UNITS_PER_WORD) && reg_classes_intersect_p (VFP_REGS, rclass)) return false; return true; diff --git a/gcc/testsuite/gcc.target/arm/big-endian-subreg.c b/gcc/testsuite/gcc.target/arm/big-endian-subreg.c new file mode 100644 index 0000000000000000000000000000000000000000..4b1ab122f349e61e296fe3f76030a7a258e55f62 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/big-endian-subreg.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-require-effective-target arm_hf_eabi } */ +/* { dg-add-options arm_neon } */ +/* { dg-additional-options "-mfp16-format=ieee -mfloat-abi=hard" } */ + +typedef __fp16 v4f16 + __attribute__ ((vector_size (8))); + +v4f16 fn1 (v4f16 p) +{ + return p; +}