From patchwork Fri Jan 18 07:54:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 213508 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]) by ozlabs.org (Postfix) with SMTP id 859A92C0080 for ; Fri, 18 Jan 2013 18:55:11 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1359100512; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=rwPzgrV ewYs+7gpJAqVgSr8G9xg=; b=bP5wpLS03AxRGJY4KILLGYovtRy/P6m7UI/FqKs BtXjJncx7qe/NJAsPKzlgETM2Cttk1KSwHoKXZ4ZLqRQD+xhHPx8Lt2cixQR8rK9 0Nzra2I/0LQffgzmAjGLm5qhuakmMRe7CbIe6W/Im7PAOz+h9YjRJ/Q+ACm7pG2S ORMg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=PAEEwGyJXcBapNBN814bkNHxr14/sxrfM/+zQXGvvJZd3UHTCRU5rBordhLQ4K 9u4hmImLmpPXZA97LSdpua1umNzdVqzqNh0naWVugsaELhHGLbA0WxgZKf1ONmPu 6U0bETLbn/88HPiZe8kJFJ2bfa5fHjngb88s7lqK52EM4=; Received: (qmail 20306 invoked by alias); 18 Jan 2013 07:55:00 -0000 Received: (qmail 20295 invoked by uid 22791); 18 Jan 2013 07:54:59 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Jan 2013 07:54:50 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0I7soSO023490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 18 Jan 2013 02:54:50 -0500 Received: from stumpy.slc.redhat.com (ovpn-113-50.phx2.redhat.com [10.3.113.50]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0I7snBe020224 for ; Fri, 18 Jan 2013 02:54:49 -0500 Message-ID: <50F8FFC9.807@redhat.com> Date: Fri, 18 Jan 2013 00:54:49 -0700 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches Subject: PR 52573 X-IsSubscribed: yes 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 I'm approving Bernd's patch referenced here: http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00421.html I've added a comment why we're ignoring the REG_DEAD notes for this particular case with a pointer back to the PR. I've also added a test to the testsuite. A prior discussion can be found here: http://gcc.gnu.org/ml/gcc/2012-03/msg00167.html Final patch is attached for historical purposes. Bootstrapped and regression tested on x86_64-linux-gnu. Also tested the new test on m68k before/after this change to verify that it failed before and passed after. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 773f4d7..e179e29 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2013-01-18 Bernd Schmidt + + PR rtl-optimization/52573 + * regrename.c (build_def_use): Ignore REG_DEAD notes if there is a + REG_UNUSED for the same register. + + 2013-01-17 Richard Biener Marek Polacek diff --git a/gcc/regrename.c b/gcc/regrename.c index df3d341..20e2ae9 100644 --- a/gcc/regrename.c +++ b/gcc/regrename.c @@ -1710,9 +1710,16 @@ build_def_use (basic_block bb) scan_rtx (insn, &XEXP (note, 0), ALL_REGS, mark_read, OP_INOUT); - /* Step 4: Close chains for registers that die here. */ + /* Step 4: Close chains for registers that die here, unless + the register is mentioned in a REG_UNUSED note. In that + case we keep the chain open until step #7 below to ensure + it conflicts with other output operands of this insn. + See PR 52573. Arguably the insn should not have both + notes; it has proven difficult to fix that without + other undesirable side effects. */ for (note = REG_NOTES (insn); note; note = XEXP (note, 1)) - if (REG_NOTE_KIND (note) == REG_DEAD) + if (REG_NOTE_KIND (note) == REG_DEAD + && !find_regno_note (insn, REG_UNUSED, REGNO (XEXP (note, 0)))) { remove_from_hard_reg_set (&live_hard_regs, GET_MODE (XEXP (note, 0)), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 21d0f05..cf1890a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-01-17 Jeff Law + + PR rtl-optimization/52573 + * gcc.dg/pr52573.c: New test. 2013-01-17 Jack Howarth PR sanitizer/55679 diff --git a/gcc/testsuite/gcc.dg/pr52573.c b/gcc/testsuite/gcc.dg/pr52573.c new file mode 100644 index 0000000..7e82749 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr52573.c @@ -0,0 +1,158 @@ + +/* { dg-do compile { target { m68k-*-* } } } */ +/* { dg-options "-w -O3 -funroll-loops" } */ +/* { dg-final { scan-assembler-not "%d0:%d0" } } */ +/* { dg-final { scan-assembler-not "%d1:%d1" } } */ +/* { dg-final { scan-assembler-not "%d2:%d2" } } */ +/* { dg-final { scan-assembler-not "%d3:%d3" } } */ +/* { dg-final { scan-assembler-not "%d4:%d4" } } */ +/* { dg-final { scan-assembler-not "%d5:%d5" } } */ +/* { dg-final { scan-assembler-not "%d6:%d6" } } */ +/* { dg-final { scan-assembler-not "%d7:%d7" } } */ +/* Test arithmetics on bitfields. */ + +extern void abort (void); +extern void exit (int); + +unsigned int +myrnd (void) +{ + static unsigned int s = 1388815473; + s *= 1103515245; + s += 12345; + return (s / 65536) % 2048; +} + +#define T(S) \ +struct S s##S; \ +struct S retme##S (struct S x) \ +{ \ + return x; \ +} \ + \ +unsigned int fn1##S (unsigned int x) \ +{ \ + struct S y = s##S; \ + y.k += x; \ + y = retme##S (y); \ + return y.k; \ +} \ + \ +unsigned int fn2##S (unsigned int x) \ +{ \ + struct S y = s##S; \ + y.k += x; \ + y.k %= 15; \ + return y.k; \ +} \ + \ +unsigned int retit##S (void) \ +{ \ + return s##S.k; \ +} \ + \ +unsigned int fn3##S (unsigned int x) \ +{ \ + s##S.k += x; \ + return retit##S (); \ +} \ + \ +void test##S (void) \ +{ \ + int i; \ + unsigned int mask, v, a, r; \ + struct S x; \ + char *p = (char *) &s##S; \ + for (i = 0; i < sizeof (s##S); ++i) \ + *p++ = myrnd (); \ + if (__builtin_classify_type (s##S.l) == 8) \ + s##S.l = 5.25; \ + s##S.k = -1; \ + mask = s##S.k; \ + v = myrnd (); \ + a = myrnd (); \ + s##S.k = v; \ + x = s##S; \ + r = fn1##S (a); \ + if (x.i != s##S.i || x.j != s##S.j \ + || x.k != s##S.k || x.l != s##S.l \ + || ((v + a) & mask) != r) \ + abort (); \ + v = myrnd (); \ + a = myrnd (); \ + s##S.k = v; \ + x = s##S; \ + r = fn2##S (a); \ + if (x.i != s##S.i || x.j != s##S.j \ + || x.k != s##S.k || x.l != s##S.l \ + || ((((v + a) & mask) % 15) & mask) != r) \ + abort (); \ + v = myrnd (); \ + a = myrnd (); \ + s##S.k = v; \ + x = s##S; \ + r = fn3##S (a); \ + if (x.i != s##S.i || x.j != s##S.j \ + || s##S.k != r || x.l != s##S.l \ + || ((v + a) & mask) != r) \ + abort (); \ +} + +struct A { unsigned int i : 6, l : 1, j : 10, k : 15; }; T(A) +struct B { unsigned int i : 6, j : 11, k : 15; unsigned int l; }; T(B) +struct C { unsigned int l; unsigned int i : 6, j : 11, k : 15; }; T(C) +struct D { unsigned long long l : 6, i : 6, j : 23, k : 29; }; T(D) +struct E { unsigned long long l, i : 12, j : 23, k : 29; }; T(E) +struct F { unsigned long long i : 12, j : 23, k : 29, l; }; T(F) +struct G { unsigned int i : 12, j : 13, k : 7; unsigned long long l; }; T(G) +struct H { unsigned int i : 12, j : 11, k : 9; unsigned long long l; }; T(H) +struct I { unsigned short i : 1, j : 6, k : 9; unsigned long long l; }; T(I) +struct J { unsigned short i : 1, j : 8, k : 7; unsigned short l; }; T(J) +struct K { unsigned int k : 6, l : 1, j : 10, i : 15; }; T(K) +struct L { unsigned int k : 6, j : 11, i : 15; unsigned int l; }; T(L) +struct M { unsigned int l; unsigned int k : 6, j : 11, i : 15; }; T(M) +struct N { unsigned long long l : 6, k : 6, j : 23, i : 29; }; T(N) +struct O { unsigned long long l, k : 12, j : 23, i : 29; }; T(O) +struct P { unsigned long long k : 12, j : 23, i : 29, l; }; T(P) +struct Q { unsigned int k : 12, j : 13, i : 7; unsigned long long l; }; T(Q) +struct R { unsigned int k : 12, j : 11, i : 9; unsigned long long l; }; T(R) +struct S { unsigned short k : 1, j : 6, i : 9; unsigned long long l; }; T(S) +struct T { unsigned short k : 1, j : 8, i : 7; unsigned short l; }; T(T) +struct U { unsigned short j : 6, k : 1, i : 9; unsigned long long l; }; T(U) +struct V { unsigned short j : 8, k : 1, i : 7; unsigned short l; }; T(V) +struct W { long double l; unsigned int k : 12, j : 13, i : 7; }; T(W) +struct X { unsigned int k : 12, j : 13, i : 7; long double l; }; T(X) +struct Y { unsigned int k : 12, j : 11, i : 9; long double l; }; T(Y) +struct Z { long double l; unsigned int j : 13, i : 7, k : 12; }; T(Z) + +int +main (void) +{ + testA (); + testB (); + testC (); + testD (); + testE (); + testF (); + testG (); + testH (); + testI (); + testJ (); + testK (); + testL (); + testM (); + testN (); + testO (); + testP (); + testQ (); + testR (); + testS (); + testT (); + testU (); + testV (); + testW (); + testX (); + testY (); + testZ (); + exit (0); +}