From patchwork Sat Mar 1 13:21:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 325417 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 AD93B2C007A for ; Sun, 2 Mar 2014 00:21:24 +1100 (EST) 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=W5GGuAR6WOQCgElfJ+4bAiSwsT4T6k8rO7Vph/mgyVVfl3 heRn9Jz30477kEoKqrRdAyXQn0R9kRbufO8EPYcqNJEm7YXUJBknNXZc+8cX3Jsa UJPzJ7FdRno+SdWTpeo335xRrQ84AzDzN23vyWBGjeytJmqmE2E+XuENaK0Tk= 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=H8inv6GACpVQeh8jxmnpKKnR0og=; b=hYG5/Oq+chX116ZmKx0y 8Y4sk8EW0a13DXMsjp/8XPGayITQAsa66UUnd2pS77uOWvU0Uce66+y5SMU1arfw JQ5DyOWWerocD08WLOKqbD5EJCaFB6o/SeURiLr4b3d3r/oAgebtsIAXWreY7B79 sQvvaBHrzlh0HyTVTlDzupM= Received: (qmail 23013 invoked by alias); 1 Mar 2014 13:21:17 -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 23002 invoked by uid 89); 1 Mar 2014 13:21:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: mailout03.t-online.de Received: from mailout03.t-online.de (HELO mailout03.t-online.de) (194.25.134.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 01 Mar 2014 13:21:15 +0000 Received: from fwd21.aul.t-online.de (fwd21.aul.t-online.de ) by mailout03.t-online.de with smtp id 1WJjqp-0004BN-HK; Sat, 01 Mar 2014 14:21:11 +0100 Received: from [192.168.0.103] (VTdMl2ZZ8heCNtGQ8xtN9WVR0GjlXLiQFFRnnkAA8l3v6TM4tv6wwZFAV6egW5ywDE@[84.175.201.41]) by fwd21.t-online.de with esmtp id 1WJjqo-0H00Se0; Sat, 1 Mar 2014 14:21:10 +0100 Message-ID: <1393680069.7310.70.camel@yam-132-YW-E178-FTW> Subject: [SH, committed] Fix PR 60071 From: Oleg Endo To: gcc-patches Date: Sat, 01 Mar 2014 14:21:09 +0100 Mime-Version: 1.0 X-IsSubscribed: yes Hi, I've just committed the attached patch that fixes PR 60071 as rev 208242. Originally tested by Kaz: http://gcc.gnu.org/ml/gcc-testresults/2014-02/msg01866.html Tested the new test case with: make check-gcc RUNTESTFLAGS="compile.exp=pr60071.c --target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" Cheers, Oleg gcc/ChangeLog: PR target/60071 * config/sh/sh.md (*mov_t_msb_neg): Split into ... (*mov_t_msb_neg_negc): ... this new insn. testsuite/ChangeLog: PR target/60071 * gcc.c-torture/compile/pr60071.c: New. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 208241) +++ gcc/config/sh/sh.md (working copy) @@ -11434,6 +11434,10 @@ ;; T = 1: 0x80000000 -> reg ;; T = 0: 0x7FFFFFFF -> reg ;; This works because 0 - 0x80000000 = 0x80000000. +;; +;; This insn must not match again after it has been split into the constant +;; load and negc. This is accomplished by the special negc insn that +;; has a use on the operand. (define_insn_and_split "*mov_t_msb_neg" [(set (match_operand:SI 0 "arith_reg_dest") (minus:SI (const_int -2147483648) ;; 0x80000000 @@ -11444,12 +11448,23 @@ "&& can_create_pseudo_p ()" [(set (match_dup 2) (const_int -2147483648)) (parallel [(set (match_dup 0) (minus:SI (neg:SI (match_dup 2)) - (reg:SI T_REG))) - (clobber (reg:SI T_REG))])] + (reg:SI T_REG))) + (clobber (reg:SI T_REG)) + (use (match_dup 2))])] { operands[2] = gen_reg_rtx (SImode); }) +(define_insn "*mov_t_msb_neg_negc" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (minus:SI (neg:SI (match_operand:SI 1 "arith_reg_operand" "r")) + (match_operand:SI 2 "t_reg_operand"))) + (clobber (reg:SI T_REG)) + (use (match_dup 1))] + "TARGET_SH1" + "negc %1,%0" + [(set_attr "type" "arith")]) + ;; These are essentially the same as above, but with the inverted T bit. ;; Combine recognizes the split patterns, but does not take them sometimes ;; if the T_REG clobber is specified. Instead it tries to split out the Index: gcc/testsuite/gcc.c-torture/compile/pr60071.c =================================================================== --- gcc/testsuite/gcc.c-torture/compile/pr60071.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/pr60071.c (revision 0) @@ -0,0 +1,8 @@ +int +foo (int cls, int sign) +{ + if (__builtin_expect (cls == 4, 0)) + return (sign + ? (-((int) ((~(unsigned)0) >> 1)))-1 + : ((int) ((~(unsigned)0) >> 1))); +}