From patchwork Wed Jan 14 17:10:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Suchanek X-Patchwork-Id: 429034 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 8168114014D for ; Thu, 15 Jan 2015 04:11:11 +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:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=DsSoJpdZ8rBstl60PuhYHGIO51lRBs0WMpi1yjNHP2AcyvYudsXQ9 WAd7B07M8F0EGsqO9YLI8YOxLyeZ41zKxQjd+Qw91lcxh0cFYQZJL1YCv3B4d3lw j5yrMHbixTfVGz8rwflxOTDQZF60rr0H6xITJqJ2/LiAllTOY0PaS0= 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:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=default; bh=M4IZUIfhgh53b2CeGPJ8lHAJmBU=; b=r8UwiGZiE8sllIsdcTEYXcj5RLgn qQgsKLQkf7g9Tmngwz7tvWYFn1I53t4TptNGfVrNhbApJpC37Uw9ZwbKLVPmCr8h 3tL6ONPO3YNMh2GdER7U5ImdBcuyYZzlru3rYplUiTIlXOC7xLnsKgi+4S+eViQr M8tRGpQUj8y3/Rc= Received: (qmail 32431 invoked by alias); 14 Jan 2015 17:11:03 -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 32417 invoked by uid 89); 14 Jan 2015 17:11:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Jan 2015 17:10:58 +0000 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id C9273A365787E; Wed, 14 Jan 2015 17:10:52 +0000 (GMT) Received: from hhmail02.hh.imgtec.org (10.100.10.20) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 14 Jan 2015 17:10:55 +0000 Received: from hhmail02.hh.imgtec.org ([::1]) by hhmail02.hh.imgtec.org ([::1]) with mapi id 14.03.0224.002; Wed, 14 Jan 2015 17:10:54 +0000 From: Robert Suchanek To: Jeff Law , Matthew Fortune , Richard Sandiford CC: Steven Bosscher , "vmakarov@redhat.com" , "gcc-patches@gcc.gnu.org" Subject: RE: [RFC, PATCH][LRA, MIPS] ICE: in decompose_normal_address, at rtlanal.c:5817 Date: Wed, 14 Jan 2015 17:10:54 +0000 Message-ID: References: <54B00CAA.60207@redhat.com> <87h9vyg5n7.fsf@googlemail.com> <6D39441BF12EF246A7ABCE6654B0235320F9D8B7@LEMAIL01.le.imgtec.org> <54B418DB.5090400@redhat.com> In-Reply-To: <54B418DB.5090400@redhat.com> MIME-Version: 1.0 Here is the revised patch that would handle the other cases as per Richard's comments. I slightly modified Matthew's proposed patch and used split_const instead of get_related_value. AFAICS, the canonical form would always have the 'plus' expression. The offset on the high part is most likely not important as the code generation has to guarantee that the low part represents the true address in the case where the high and lo_sum are directly related. Regards, Robert gcc/ * simplify-rtx.c (simplify_replace_fn_rtx): Simplify (lo_sum (high x) y) to y if x and y have the same base. gcc/testsuite/ * gcc.c-torture/compile/20150108.c: New test. > -----Original Message----- > From: Jeff Law [mailto:law@redhat.com] > Sent: 12 January 2015 18:56 > To: Matthew Fortune; Richard Sandiford > Cc: Robert Suchanek; Steven Bosscher; vmakarov@redhat.com; gcc- > patches@gcc.gnu.org > Subject: Re: [RFC, PATCH][LRA, MIPS] ICE: in decompose_normal_address, at > rtlanal.c:5817 > > On 01/10/15 09:35, Matthew Fortune wrote: > > > > I guess so. I took the phrasing below for (high:m exp) to mean that high > > only made sense when used with lo_sum. > True. But one can use a single high with different lo_sum expressions > when those lo_sum expressions are related. > > So you might have a single high such as > > (high (symbol_ref "x")) > > That feeds multiple lo_sum expressions like > > (lo_sum (reg) (symbol_ref "x")) > (lo_sum (reg) (const (plus (symbol_ref "x") (const_int 4)))) > (lo_sum (reg) (const (plus (symbol_ref "x") (const_int 8)))) > (lo_sum (reg) (const (plus (symbol_ref "x") (const_int 12))) > > > IIRC this gets implemented in either the move expander or a > legitimize_address hook. You start with a high/lo_sum pair for each > reference. However, you rewrite the high part to chop off low bits. > That makes many of the high expressions become common subexpressions and > they get removed by CSE in the expected ways. > > You have to be careful for overflows and such. I don't recall the > precise rules there, but it was the source of problems with interfacing > with the optimizing PA linker. > > > Jeff diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 04af01e..df86f8b 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -499,9 +499,15 @@ simplify_replace_fn_rtx (rtx x, const_rtx old_rtx, op0 = simplify_replace_fn_rtx (XEXP (x, 0), old_rtx, fn, data); op1 = simplify_replace_fn_rtx (XEXP (x, 1), old_rtx, fn, data); - /* (lo_sum (high x) x) -> x */ - if (GET_CODE (op0) == HIGH && rtx_equal_p (XEXP (op0, 0), op1)) - return op1; + /* (lo_sum (high x) y) -> y where x and y have the same base. */ + if (GET_CODE (op0) == HIGH) + { + rtx base0, base1, offset0, offset1; + split_const (XEXP (op0, 0), &base0, &offset0); + split_const (op1, &base1, &offset1); + if (rtx_equal_p (base0, base1)) + return op1; + } if (op0 == XEXP (x, 0) && op1 == XEXP (x, 1)) return x; diff --git a/gcc/testsuite/gcc.c-torture/compile/20150108.c b/gcc/testsuite/gcc.c-torture/compile/20150108.c new file mode 100644 index 0000000..15c53e3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20150108.c @@ -0,0 +1,23 @@ +long long a[10]; +long long b, c, d, k, m, n, o, p, q, r, s, t, u, v, w; +int e, f, g, h, i, j, l, x; + +int fn1 () { + for (; x; x++) + if (x & 1) + s = h | g; + else + s = f | e; + l = ~0; + m = 1 | k; + n = i; + o = j; + p = f | e; + q = h | g; + w = d | c | a[1]; + t = c; + v = b | c; + u = v; + r = b | a[4]; + return e; +