From patchwork Fri Nov 7 15:58:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preud'homme X-Patchwork-Id: 408176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 2FCA31400A6 for ; Sat, 8 Nov 2014 02:58:22 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=rGcDbNyUl28xGlYY Gz0uACcf0xht/0i9PlF3PapGlz/kyHomQnmEumpeaNo/OAwpxq1Rh5//ANApCWPg 9QfdJQf1HacWAKcJaq7J0z64rSIHWZVtZ5CICgsW9oNVrUMG8Zd9GCxzO2QFX0G7 cfHbQyCyPPIFxtm+HoY35vVPeaI= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=Uuk+EO6BAO2Df6w25gfugb z2Ugk=; b=kn3lS+B0pQPLqFYdTzMOEZ97+UlE6sXlmKXmKi6VhbYX/w07PA0pFT pp8lZ26rUrFCZJSzkPHZ0g18SqotEaf/CCilEDFT+GXIydbnru9VQMNrgGMHsAtv CR1wcF+78XV6tClOI2P3KDPf7zbNOzMLFTMUWIsV+pTBCoj3gyNns= Received: (qmail 28705 invoked by alias); 7 Nov 2014 15:58:14 -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 28695 invoked by uid 89); 7 Nov 2014 15:58:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Nov 2014 15:58:12 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 07 Nov 2014 15:58:09 +0000 Received: from SHAWIN202 ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 7 Nov 2014 15:58:07 +0000 From: "Thomas Preud'homme" To: , "Richard Biener" Subject: [PATCH] Fix bswap regression: expand 8bit rotations of 16bit values into bswaphi patterns Date: Fri, 7 Nov 2014 15:58:01 -0000 Message-ID: <000101cffaa3$9be23460$d3a69d20$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114110715581000101 X-IsSubscribed: yes Trunk revision 216971 introduced LROTATE_EXPR as the canonical representation for a byte swap of a 2 bytes value, as per [1]. However, backend expects bswaphi patterns for such operation as these operation are more specific than a rotation. This led to a number of testcases starting to fail such as gcc.target/arm/builtin-bswap16-1.c and gcc.target/aarch64/builtin-bswap-2.c (these were skipped with my configuration). This patch adds a check in expmed to expand such LROTATE_EXPR into bswaphi pattern. [1] https://gcc.gnu.org/ml/gcc-patches/2014-10/msg00616.html Note that this is unrelated to PR63761 (but I have diagnosed the root cause). ChangeLog entry is as follows: 2014-11-03 Thomas Preud'homme * expmed.c (expand_shift_1): Expand 8 bit rotate of 16 bit value to bswaphi if available. Is this ok for trunk? With the right configuration I could reproduce the test failure and with this patch both tests fail. Best regards, Thomas diff --git a/gcc/expmed.c b/gcc/expmed.c index af14b99..7e86b59 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -2164,6 +2164,14 @@ expand_shift_1 (enum tree_code code, machine_mode mode, rtx shifted, code = left ? LROTATE_EXPR : RROTATE_EXPR; } + if (rotate + && CONST_INT_P (op1) + && INTVAL (op1) == BITS_PER_UNIT + && GET_MODE_SIZE (scalar_mode) == 2 + && optab_handler (bswap_optab, HImode) != CODE_FOR_nothing) + return expand_unop (HImode, bswap_optab, shifted, NULL_RTX, + unsignedp); + if (op1 == const0_rtx) return shifted;