From patchwork Mon Nov 16 14:25:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 545032 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 838EE14146A for ; Tue, 17 Nov 2015 01:25:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WTzXlAG+; 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:subject:from:to:date:content-type:mime-version; q= dns; s=default; b=gMMOrSXkoJWNhSnQHRC6BrnF1GgfmahNQkW2XsCfyLxRKL RKU2dz2CT9WFHTcs47AJAI2AfWqvpKzi55PazUUk7a8hUduOumIpZPGz95WR4lJ7 kdYfzY+whxQbpQcFZ6BVToJWiRlEKc3BnNRUeMwwCiC/0Zfme5QH7kK3Ht9+I= 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:subject:from:to:date:content-type:mime-version; s= default; bh=xE/DYFDu63bHvmukYQVS2lHRjUs=; b=WTzXlAG+JIXeQZ7CiOj/ sq49+z6rA6XSLcSgsclQHNypNmANQxszOBdDTqNzDiXDHOwkabkKlskZPNC1zTY0 ez32PLQZoaeCwZNlG80PHuZ7MpXdRihMoXBAqvxbbaAav+YSGFWJXBke+zJnqAS6 EIRpU/JKRc28X62gsjer5lY= Received: (qmail 42212 invoked by alias); 16 Nov 2015 14:25:44 -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 41512 invoked by uid 89); 16 Nov 2015 14:25:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mailout10.t-online.de Received: from mailout10.t-online.de (HELO mailout10.t-online.de) (194.25.134.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 16 Nov 2015 14:25:39 +0000 Received: from fwd28.aul.t-online.de (fwd28.aul.t-online.de [172.20.26.133]) by mailout10.t-online.de (Postfix) with SMTP id 96C8F18A59D for ; Mon, 16 Nov 2015 15:25:35 +0100 (CET) Received: from [192.168.0.16] (Tn8fmaZaoh2E8rNMpB5nqhGmZzL12ISIN66oKOnCHizHfaIiLUrpY3y9jlt0h5vw3H@[115.165.93.200]) by fwd28.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1ZyKiq-3MKCEC0; Mon, 16 Nov 2015 15:25:32 +0100 Message-ID: <1447683928.2230.108.camel@t-online.de> Subject: [SH][committed] Fix PR 68277 From: Oleg Endo To: gcc-patches Date: Mon, 16 Nov 2015 23:25:28 +0900 Mime-Version: 1.0 X-IsSubscribed: yes Hi, The attached patch fixes PR 68277. Tested by Kaz on trunk on sh4-linux. I've also done a sanity check on GCC 5 branch with "make all" on sh-elf. Committed to trunk as r230425 and to GCC 5 branch as r230426. Cheers, Oleg gcc/ChangeLog: PR target/68277 * config/sh/sh.md (addsi3_scr): Handle reg overlap of operands[0] and operands[2]. (*addsi3): Add another insn_and_split variant for reload. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 230158) +++ gcc/config/sh/sh.md (working copy) @@ -2232,11 +2232,51 @@ } } else if (!reg_overlap_mentioned_p (operands[0], operands[1])) - emit_move_insn (operands[0], operands[1]); + { + if (!reg_overlap_mentioned_p (operands[0], operands[2])) + emit_move_insn (operands[0], operands[1]); + else + operands[2] = operands[1]; + } } [(set_attr "type" "arith")]) +;; Old reload might generate add insns directly (not through the expander) for +;; the memory address of complex insns like atomic insns when reloading. (define_insn_and_split "*addsi3" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (plus:SI (match_operand:SI 1 "arith_reg_operand" "r") + (match_operand:SI 2 "arith_or_int_operand" "rn")))] + "TARGET_SH1 && !sh_lra_p () + && reload_completed + && !reg_overlap_mentioned_p (operands[0], operands[1])" + "#" + "&& 1" + [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))] +{ + if (operands[2] == const0_rtx) + { + emit_move_insn (operands[0], operands[1]); + DONE; + } + + if (CONST_INT_P (operands[2])) + { + if (satisfies_constraint_I08 (operands[2])) + emit_move_insn (operands[0], operands[1]); + else + { + emit_move_insn (operands[0], operands[2]); + operands[2] = operands[1]; + } + } + else if (!reg_overlap_mentioned_p (operands[0], operands[2])) + emit_move_insn (operands[0], operands[1]); + else + operands[2] = operands[1]; +}) + +(define_insn_and_split "*addsi3" [(set (match_operand:SI 0 "arith_reg_dest" "=r,r") (plus:SI (match_operand:SI 1 "arith_reg_operand" "%0,r") (match_operand:SI 2 "arith_operand" "rI08,Z")))]