From patchwork Thu Dec 10 14:36:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 555163 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 91AD6140213 for ; Fri, 11 Dec 2015 01:36:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=a5+5dBP4; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=hApXyB/rLYBliC16IyJfPTJuDm+1kZ0FbIhJn+IJtiK zoR1TNCFtMUdP+/wIhR/nmvVc9akBz+GPaTG83vcZpa1Kg6HAkzemXa/3bam6Him xoI6mxw6iclwnFdsyn72bc9BR+qze/M/h5AH9DQv6tnaxhTAO8b10k8wqIAqY/vQ = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=wDLll56SCa4nYPCjFAXqiOT1K8c=; b=a5+5dBP40mRD57z3Y vqnFF5PiB1dlSwHrMlWmIFrZ1ucVXe2+VrKobTetxhSiiDRSOOoxgTrbRg/rjcNd scpGsEv3+NOzjCmxyrJwc1MuU44tbHpGK+w+qEM6rvi8wE57hVaoAx1djuDXvk7R hMzTiYAsXr4vPmCWDTEtflBKuA= Received: (qmail 69950 invoked by alias); 10 Dec 2015 14:36:15 -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 69935 invoked by uid 89); 10 Dec 2015 14:36:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Dec 2015 14:36:13 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-10-ylObqTRYQOuk45rw-riqBg-1; Thu, 10 Dec 2015 14:36:06 +0000 Received: from [10.2.206.200] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Dec 2015 14:36:05 +0000 Message-ID: <56698DD5.3010105@arm.com> Date: Thu, 10 Dec 2015 14:36:05 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Segher Boessenkool Subject: [PATCH][combine] Don't create LSHIFTRT of zero bits in change_zero_ext X-MC-Unique: ylObqTRYQOuk45rw-riqBg-1 X-IsSubscribed: yes Hi all, At the end of combine if it fails to recognise the patterns it produces it tries again after transforming all zero_extends and zero_extracts into and-immediate plus an LSHIFTRT if needed. However, it will construct an LSHIFTRT inside the AND even if the shift distance is 0, which can hurt recognisability. This patch fixes that by not creating the LSHIFRT of zero. I hit this when I was experimenting with some new backend patterns and other unrelated combine changes, so I don't have a testcase that shows this on a clean trunk, but I believe this could hurt recognisability in the future. Bootstrapped and tested on arm, aarch64, x86_64. I didn't see any codegen differences with clean trunk on aarch64 SPEC2006. I'm okay with delaying this for next stage 1 if people prefer, though I think it's pretty low risk. What do people think? Kyrill 2015-12-10 Kyrylo Tkachov * combine.c (change_zero_ext): Do not create a shift of zero length. diff --git a/gcc/combine.c b/gcc/combine.c index 7d4ffbcc766113c0af1c903f3d0dadbe74dec7fa..2628e1a437c2cd63d439a3ad28d1799b8c679be3 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11037,7 +11037,9 @@ change_zero_ext (rtx *src) if (BITS_BIG_ENDIAN) start = GET_MODE_PRECISION (mode) - size - start; - x = gen_rtx_LSHIFTRT (mode, XEXP (x, 0), GEN_INT (start)); + x = XEXP (x, 0); + if (start > 0) + x = gen_rtx_LSHIFTRT (mode, x, GEN_INT (start)); } else if (GET_CODE (x) == ZERO_EXTEND && GET_CODE (XEXP (x, 0)) == SUBREG