From patchwork Tue Sep 15 06:39:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Miller X-Patchwork-Id: 517688 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 54EAF140187 for ; Tue, 15 Sep 2015 16:40:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=vu0yPZ4L; 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:date :message-id:to:cc:subject:from:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Sw1ymjaeqFRjzU/e GgyG5Ki19+qYAqkVgapn9aQLvG2Invh82ydF9+niYuWjlE47sOKdo89irzgE008A rdXIo8/x4nByzAsi9Wcogvrd/Qzk+R47Y3gh/BqGfhM1QPxXTdy7ea53bkt9w64e fWn3tdUEY1h8CTbh3wDc2sCw7DA= 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 :message-id:to:cc:subject:from:mime-version:content-type :content-transfer-encoding; s=default; bh=EEK2CinHSr+ORqkkW4tCS2 2V/E8=; b=vu0yPZ4LUQ7S/jmJ4HdzjyG/og7DBRPDeUYFD2PGmBGuT/KaEo4rrM 7gQS6liEn3sh40J6iL8pIFlczlEP/v6DpTyBhBj6rEGLNnqeEJIv+pGakocPpG7W n4uTevHeowMPz3m6Iou3o1NC6tC/FzO66q38ZWIRHDRBhJMcwjfdA= Received: (qmail 100934 invoked by alias); 15 Sep 2015 06:39:57 -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 100922 invoked by uid 89); 15 Sep 2015 06:39:56 -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, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: shards.monkeyblade.net Received: from shards.monkeyblade.net (HELO shards.monkeyblade.net) (149.20.54.216) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Sep 2015 06:39:55 +0000 Received: from localhost (74-93-104-98-Washington.hfc.comcastbusiness.net [74.93.104.98]) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 5A4F4594E1C; Mon, 14 Sep 2015 23:39:52 -0700 (PDT) Date: Mon, 14 Sep 2015 23:39:49 -0700 (PDT) Message-Id: <20150914.233949.1198971614113485779.davem@davemloft.net> To: gcc-patches@gcc.gnu.org CC: vmakarov@redhat.com Subject: [PATCH] Fix endianness assumption in LRA From: David Miller Mime-Version: 1.0 X-IsSubscribed: yes This was the most glaring case, and would result in LRA crashing if this code snippet was actually hit on big-endian, since simplify_gen_subreg() will return NULL in such a case and then we try to blindly emit a move to 'subreg'. There is code in match_reload which seems to have a similar problem, specifically these sequences: if (SCALAR_INT_MODE_P (inmode)) new_out_reg = gen_lowpart_SUBREG (outmode, reg); else new_out_reg = gen_rtx_SUBREG (outmode, reg, 0); ... if (SCALAR_INT_MODE_P (outmode)) new_in_reg = gen_lowpart_SUBREG (inmode, reg); else new_in_reg = gen_rtx_SUBREG (inmode, reg, 0); But I have not tried to address those cases in this patch. Vlad, is this OK to commit? 2015-09-14 David S. Miller * lra-constraints.c (simplify_operand_subreg): Do not assume that lowpart of a SUBREG has offset zero. diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index cdb2695..fc8e43d 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -1545,7 +1545,7 @@ simplify_operand_subreg (int nop, machine_mode reg_mode) bool insert_before, insert_after; PUT_MODE (new_reg, mode); - subreg = simplify_gen_subreg (innermode, new_reg, mode, 0); + subreg = gen_lowpart_SUBREG (innermode, new_reg); bitmap_set_bit (&lra_subreg_reload_pseudos, REGNO (new_reg)); insert_before = (type != OP_OUT);