From patchwork Thu Jan 26 17:09:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 720301 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 3v8T0z3XvBz9tk1 for ; Fri, 27 Jan 2017 04:09:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="eoU+8Sus"; 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:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=Y+9jltT0thgeHhxEY2fWF92+Hp4yr864zRegCqF05PfRk3JZScu9+ 04OmMzR00BEJIoXGWcuORcBHcjvWM1BJ6diRuLxN4uvRm03HDvq0CrKPPQmW48rx 30RqARojWEScEPZjc7xaj/Qx/2sKsV77iAvTmxcKbGxePFOx8fX0HA= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=tLq2+r6E87sJNuarUrxNujK4O9M=; b=eoU+8SusrAB1g3xlqqh/ GGiqpL5mjBcOILk/1+OOIL6pUkeWLr8VqBUV6+reFpDXzarrKXOIBmDnydQFRhL5 esWKiMLjg3wgQCXSQq8/z2+d/gevm9RPz7S2SR9HThwUf2eNVzyyLOE4D5cZdQhb hVbT2sfX4llaDlWm7rHZkec= Received: (qmail 48064 invoked by alias); 26 Jan 2017 17:09:13 -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 48053 invoked by uid 89); 26 Jan 2017 17:09:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:get_cal, assignments X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Jan 2017 17:09:02 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 523EC6AAF2 for ; Thu, 26 Jan 2017 17:09:02 +0000 (UTC) Received: from [10.10.118.116] (ovpn-118-116.rdu2.redhat.com [10.10.118.116]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0QH91P1006552 for ; Thu, 26 Jan 2017 12:09:01 -0500 From: Vladimir Makarov Subject: Patch to fix PR79131 To: "gcc-patches@gcc.gnu.org" Message-ID: <49091620-2b61-fe51-d00f-f8e567bb5f62@redhat.com> Date: Thu, 26 Jan 2017 12:09:00 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79131 The patch also adapts IP IRA in LRA because without it GCC IP RA tests become broken (it was just a luck that the tests worked before the patch). The patch was successfully bootstrapped and tested on x86-64. Committed as rev. 244942. Index: ChangeLog =================================================================== --- ChangeLog (revision 244937) +++ ChangeLog (working copy) @@ -1,3 +1,16 @@ +2017-01-26 Vladimir Makarov + + PR target/79131 + * lra-assigns.c (setup_live_pseudos_and_spill_after_risky): Take + endianess for subregs into account. + * lra-constraints.c (lra_constraints): Do risky transformations + always on the first iteration. + * lra-lives.c (check_pseudos_live_through_calls): Add arg + last_call_used_reg_set. + (process_bb_lives): Define and use last_call_used_reg_set. + * lra.c (lra): Always continue after lra_constraints on the first + iteration. + 2017-01-26 Jakub Jelinek * config/i386/avx512fintrin.h (_ktest_mask16_u8, Index: lra-assigns.c =================================================================== --- lra-assigns.c (revision 244595) +++ lra-assigns.c (working copy) @@ -1179,9 +1179,19 @@ setup_live_pseudos_and_spill_after_risky /* If it is multi-register pseudos they should start on the same hard register. */ || hard_regno != reg_renumber[conflict_regno]) - add_to_hard_reg_set (&conflict_set, - lra_reg_info[conflict_regno].biggest_mode, - reg_renumber[conflict_regno]); + { + int conflict_hard_regno = reg_renumber[conflict_regno]; + machine_mode biggest_mode = lra_reg_info[conflict_regno].biggest_mode; + int biggest_nregs = hard_regno_nregs[conflict_hard_regno][biggest_mode]; + int nregs_diff = (biggest_nregs + - (hard_regno_nregs + [conflict_hard_regno] + [PSEUDO_REGNO_MODE (conflict_regno)])); + add_to_hard_reg_set (&conflict_set, + biggest_mode, + conflict_hard_regno + - (WORDS_BIG_ENDIAN ? nregs_diff : 0)); + } if (! overlaps_hard_reg_set_p (conflict_set, mode, hard_regno)) { update_lives (regno, false); Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 244595) +++ lra-constraints.c (working copy) @@ -4511,7 +4511,10 @@ lra_constraints (bool first_p) && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER) lra_risky_transformations_p = true; else - lra_risky_transformations_p = false; + /* On the first iteration we should check IRA assignment + correctness. In rare cases, the assignments can be wrong as + early clobbers operands are ignored in IRA. */ + lra_risky_transformations_p = first_p; new_insn_uid_start = get_max_uid (); new_regno_start = first_p ? lra_constraint_new_regno_start : max_reg_num (); /* Mark used hard regs for target stack size calulations. */ Index: lra-lives.c =================================================================== --- lra-lives.c (revision 244595) +++ lra-lives.c (working copy) @@ -560,10 +560,11 @@ lra_setup_reload_pseudo_preferenced_hard } /* Check that REGNO living through calls and setjumps, set up conflict - regs, and clear corresponding bits in PSEUDOS_LIVE_THROUGH_CALLS and - PSEUDOS_LIVE_THROUGH_SETJUMPS. */ + regs using LAST_CALL_USED_REG_SET, and clear corresponding bits in + PSEUDOS_LIVE_THROUGH_CALLS and PSEUDOS_LIVE_THROUGH_SETJUMPS. */ static inline void -check_pseudos_live_through_calls (int regno) +check_pseudos_live_through_calls (int regno, + HARD_REG_SET last_call_used_reg_set) { int hr; @@ -571,7 +572,7 @@ check_pseudos_live_through_calls (int re return; sparseset_clear_bit (pseudos_live_through_calls, regno); IOR_HARD_REG_SET (lra_reg_info[regno].conflict_hard_regs, - call_used_reg_set); + last_call_used_reg_set); for (hr = 0; hr < FIRST_PSEUDO_REGISTER; hr++) if (HARD_REGNO_CALL_PART_CLOBBERED (hr, PSEUDO_REGNO_MODE (regno))) @@ -604,11 +605,13 @@ process_bb_lives (basic_block bb, int &c rtx_insn *next; rtx link, *link_loc; bool need_curr_point_incr; - + HARD_REG_SET last_call_used_reg_set; + reg_live_out = df_get_live_out (bb); sparseset_clear (pseudos_live); sparseset_clear (pseudos_live_through_calls); sparseset_clear (pseudos_live_through_setjumps); + CLEAR_HARD_REG_SET (last_call_used_reg_set); REG_SET_TO_HARD_REG_SET (hard_regs_live, reg_live_out); AND_COMPL_HARD_REG_SET (hard_regs_live, eliminable_regset); EXECUTE_IF_SET_IN_BITMAP (reg_live_out, FIRST_PSEUDO_REGISTER, j, bi) @@ -795,7 +798,8 @@ process_bb_lives (basic_block bb, int &c need_curr_point_incr |= mark_regno_live (reg->regno, reg->biggest_mode, curr_point); - check_pseudos_live_through_calls (reg->regno); + check_pseudos_live_through_calls (reg->regno, + last_call_used_reg_set); } for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next) @@ -831,15 +835,27 @@ process_bb_lives (basic_block bb, int &c if (call_p) { - if (flag_ipa_ra) + if (! flag_ipa_ra) + COPY_HARD_REG_SET(last_call_used_reg_set, call_used_reg_set); + else { HARD_REG_SET this_call_used_reg_set; get_call_reg_set_usage (curr_insn, &this_call_used_reg_set, call_used_reg_set); + bool flush = (! hard_reg_set_empty_p (last_call_used_reg_set) + && ! hard_reg_set_equal_p (last_call_used_reg_set, + this_call_used_reg_set)); + EXECUTE_IF_SET_IN_SPARSESET (pseudos_live, j) - IOR_HARD_REG_SET (lra_reg_info[j].actual_call_used_reg_set, - this_call_used_reg_set); + { + IOR_HARD_REG_SET (lra_reg_info[j].actual_call_used_reg_set, + this_call_used_reg_set); + if (flush) + check_pseudos_live_through_calls + (j, last_call_used_reg_set); + } + COPY_HARD_REG_SET(last_call_used_reg_set, this_call_used_reg_set); } sparseset_ior (pseudos_live_through_calls, @@ -866,7 +882,8 @@ process_bb_lives (basic_block bb, int &c need_curr_point_incr |= mark_regno_live (reg->regno, reg->biggest_mode, curr_point); - check_pseudos_live_through_calls (reg->regno); + check_pseudos_live_through_calls (reg->regno, + last_call_used_reg_set); } for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next) @@ -1009,7 +1026,7 @@ process_bb_lives (basic_block bb, int &c if (sparseset_cardinality (pseudos_live_through_calls) == 0) break; if (sparseset_bit_p (pseudos_live_through_calls, j)) - check_pseudos_live_through_calls (j); + check_pseudos_live_through_calls (j, last_call_used_reg_set); } if (need_curr_point_incr) Index: lra.c =================================================================== --- lra.c (revision 244595) +++ lra.c (working copy) @@ -2295,7 +2295,7 @@ void lra (FILE *f) { int i; - bool live_p, scratch_p, inserted_p; + bool live_p, inserted_p; lra_dump_file = f; @@ -2332,7 +2332,6 @@ lra (FILE *f) lra_constraint_new_regno_start = lra_new_regno_start = max_reg_num (); lra_bad_spill_regno_start = INT_MAX; remove_scratches (); - scratch_p = lra_constraint_new_regno_start != max_reg_num (); /* A function that has a non-local label that can reach the exit block via non-exceptional paths must save all call-saved @@ -2372,11 +2371,12 @@ lra (FILE *f) for (;;) { /* We should try to assign hard registers to scratches even - if there were no RTL transformations in - lra_constraints. */ + if there were no RTL transformations in lra_constraints. + Also we should check IRA assignments on the first + iteration as they can be wrong because of early clobbers + operands which are ignored in IRA. */ if (! lra_constraints (lra_constraint_iter == 0) - && (lra_constraint_iter > 1 - || (! scratch_p && ! caller_save_needed))) + && lra_constraint_iter > 1) break; /* Constraint transformations may result in that eliminable hard regs become uneliminable and pseudos which use them Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 244937) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2017-01-26 Vladimir Makarov + + PR target/79131 + * gcc.target/arm/pr79131.c: New. + 2017-01-26 Bin Cheng * gcc.target/aarch64/ldp_vec_64_1.c: Xfail. Index: testsuite/gcc.target/arm/pr79131.c =================================================================== --- testsuite/gcc.target/arm/pr79131.c (revision 0) +++ testsuite/gcc.target/arm/pr79131.c (working copy) @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mbig-endian" } */ + +long long a; +enum { NILFS_SEGMENT_USAGE_ACTIVE, NILFS_SEGMENT_USAGE_DIRTY } b; +void nilfs_sufile_mod_counter(long long p1) { + long c = p1; + unsigned d = __builtin_bswap64(a); + a = __builtin_bswap64(d + c); +} +void nilfs_sufile_do_free() { + int e, f; + e = __builtin_bswap32(b) & 1 << NILFS_SEGMENT_USAGE_DIRTY; + f = e; + nilfs_sufile_mod_counter(f ? -1 : 0); +}