From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106868 invoked by alias); 31 Jul 2015 09:26:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 106798 invoked by uid 89); 31 Jul 2015 09:26:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 Jul 2015 09:26:16 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-37-k8ojuukyTF209YdXiqqaxg-1; Fri, 31 Jul 2015 10:26:11 +0100 Received: from SHAWIN202 ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 31 Jul 2015 10:26:10 +0100 From: "Thomas Preud'homme" To: "Jeff Law" , Subject: [PATCH, loop-invariant] Fix PR67043: -fcompare-debug failure with -O3 Date: Fri, 31 Jul 2015 09:36:00 -0000 Message-ID: <000001d0cb72$ea66f2b0$bf34d810$@arm.com> MIME-Version: 1.0 X-MC-Unique: k8ojuukyTF209YdXiqqaxg-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg02631.txt.bz2 Hi, Since commit r223113, loop-invariant pass rely on luids to determine if an = invariant can be hoisted out of a loop without introducing temporaries. How= ever, nothing is made to ensure luids are up-to-date. This patch adds a DF_= LIVE problem and mark all blocks as dirty before using luids to ensure thes= e will be recomputed. ChangeLog entries are as follows: 2015-07-31 Thomas Preud'homme PR tree-optimization/67043 * loop-invariant.c (find_defs): Force recomputation of all luids. 2015-07-29 Thomas Preud'homme PR tree-optimization/67043 * gcc.dg/pr67043.c: New test. Note: the testcase was heavily reduced from the Linux kernel sources by Mar= kus Trippelsdorf and formatted to follow GNU code style. diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 1fdb84d..fc53e09 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -676,6 +676,8 @@ find_defs (struct loop *loop) df_remove_problem (df_chain); df_process_deferred_rescans (); df_chain_add_problem (DF_UD_CHAIN); + df_live_add_problem (); + df_live_set_all_dirty (); df_set_flags (DF_RD_PRUNE_DEAD_DEFS); df_analyze_loop (loop); check_invariant_table_size (); diff --git a/gcc/testsuite/gcc.dg/pr67043.c b/gcc/testsuite/gcc.dg/pr67043.c new file mode 100644 index 0000000..36aa686 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr67043.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug -w" } */ + +extern void rt_mutex_owner (void); +extern void rt_mutex_deadlock_account_lock (int); +extern void signal_pending (void); +__typeof__ (int *) a; +int b; + +int +try_to_take_rt_mutex (int p1) { + rt_mutex_owner (); + if (b) + return 0; + rt_mutex_deadlock_account_lock (p1); + return 1; +} + +void +__rt_mutex_slowlock (int p1) { + int c; + for (;;) { + c =3D ({ + asm ("" : "=3Dr"(a)); + a; + }); + if (try_to_take_rt_mutex (c)) + break; + if (__builtin_expect (p1 =3D=3D 0, 0)) + signal_pending (); + } +} Patch was tested by running the testsuite against a bootstrapped native x86= _64-linux-gnu GCC and against an arm-none-eabi GCC cross-compiler without a= ny regression. Is this ok for trunk? Best regards, Thomas Preud'homme