From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9972 invoked by alias); 27 Oct 2015 14:49:39 -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 9962 invoked by uid 89); 27 Oct 2015 14:49:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 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; Tue, 27 Oct 2015 14:49:36 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-19-0yBBl7LAQ2WTXZAi6ySSPg-1; Tue, 27 Oct 2015 14:49:31 +0000 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 27 Oct 2015 14:49:31 +0000 Message-ID: <562F8EFB.9080000@arm.com> Date: Tue, 27 Oct 2015 14:49:00 -0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches Subject: [PATCH][RTL-ifcvt] PR rtl-optimization/67749: Do not emit separate SET insn in IF-ELSE case X-MC-Unique: 0yBBl7LAQ2WTXZAi6ySSPg-1 Content-Type: multipart/mixed; boundary="------------080101090807040306090902" X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg02912.txt.bz2 This is a multi-part message in MIME format. --------------080101090807040306090902 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 1219 Hi all, This patch fixes the gcc.dg/ifcvt-2.c test for x86_64 where we were failing= to if-convert. This was because in my patch at https://gcc.gnu.org/viewcvs/gcc?view=3Drevi= sion&revision=3D228194 which tried to emit a SET to move the source of insn_a or insn_b (that came= from the test block) into a temporary. A SET however, is not always enough. For example, on x86_= 64 in order for the resulting insn to be recognised it frequently needs to be in PARALLEL with = a (clobber (reg:CC FLAGS_REG)). This leads to the insn not being recognised. So this patch removes that SET and instead generates a couple of temporary = pseudos that gets passed on a bit later to the code that loads the operands into registers when they= 're not general_operand. This way we just modify the existing (recognisable) sets, allowing us to if= -convert the testcase. Bootstrapped and tested on x86_64, arm, aarch64. Ok for trunk? Thanks, Kyrill 2015-10-27 Kyrylo Tkachov PR rtl-optimization/67749 * ifcvt.c (noce_try_cmove_arith): Do not emit move in IF-ELSE case before emitting the two blocks. Instead modify the register in the corresponding final insn of the basic block. --------------080101090807040306090902 Content-Type: text/x-patch; name=ifcvt-x86-test.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ifcvt-x86-test.patch" Content-length: 4876 commit d58740af39ceaf2d654cf3feff97b39fb6da3e82 Author: Kyrylo Tkachov Date: Tue Sep 29 13:44:21 2015 +0100 [RTL-ifcvt] PR rtl-optimization/67749 diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 8846e69..7c6e7ca 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -2135,38 +2135,29 @@ noce_try_cmove_arith (struct noce_if_info *if_info) emit might clobber the register used by B or A, so move it to a pseudo first. */ =20 + rtx tmp_a =3D NULL_RTX; + rtx tmp_b =3D NULL_RTX; + if (b_simple || !else_bb) - { - rtx tmp_b =3D gen_reg_rtx (x_mode); - /* Perform the simplest kind of set. The register allocator - should remove it if it's not actually needed. If this set is not - a valid insn (can happen on the is_mem path) then end_ifcvt_sequence - will cancel the whole sequence. Don't try any of the fallback paths - from noce_emit_move_insn since we want this to be the simplest kind - of move. */ - emit_insn (gen_rtx_SET (tmp_b, b)); - b =3D tmp_b; - } + tmp_b =3D gen_reg_rtx (x_mode); =20 if (a_simple || !then_bb) - { - rtx tmp_a =3D gen_reg_rtx (x_mode); - emit_insn (gen_rtx_SET (tmp_a, a)); - a =3D tmp_a; - } + tmp_a =3D gen_reg_rtx (x_mode); =20 orig_a =3D a; orig_b =3D b; =20 rtx emit_a =3D NULL_RTX; rtx emit_b =3D NULL_RTX; - + rtx_insn *tmp_insn =3D NULL; + bool modified_in_a =3D false; + bool modified_in_b =3D false; /* If either operand is complex, load it into a register first. The best way to do this is to copy the original insn. In this way we preserve any clobbers etc that the insn may have had. This is of course not possible in the IS_MEM case. */ =20 - if (! general_operand (a, GET_MODE (a))) + if (! general_operand (a, GET_MODE (a)) || tmp_a) { =20 if (is_mem) @@ -2174,36 +2165,51 @@ noce_try_cmove_arith (struct noce_if_info *if_info) rtx reg =3D gen_reg_rtx (GET_MODE (a)); emit_a =3D gen_rtx_SET (reg, a); } - else if (! insn_a) - goto end_seq_and_fail; else { - a =3D gen_reg_rtx (GET_MODE (a)); - rtx_insn *copy_of_a =3D as_a (copy_rtx (insn_a)); - rtx set =3D single_set (copy_of_a); - SET_DEST (set) =3D a; + if (insn_a) + { + a =3D tmp_a ? tmp_a : gen_reg_rtx (GET_MODE (a)); + + rtx_insn *copy_of_a =3D as_a (copy_rtx (insn_a)); + rtx set =3D single_set (copy_of_a); + SET_DEST (set) =3D a; =20 - emit_a =3D PATTERN (copy_of_a); + emit_a =3D PATTERN (copy_of_a); + } + else + { + rtx tmp_reg =3D tmp_a ? tmp_a : gen_reg_rtx (GET_MODE (a)); + emit_a =3D gen_rtx_SET (tmp_reg, a); + a =3D tmp_reg; + } } } =20 - if (! general_operand (b, GET_MODE (b))) + if (! general_operand (b, GET_MODE (b)) || tmp_b) { if (is_mem) { rtx reg =3D gen_reg_rtx (GET_MODE (b)); emit_b =3D gen_rtx_SET (reg, b); } - else if (! insn_b) - goto end_seq_and_fail; else { - b =3D gen_reg_rtx (GET_MODE (b)); - rtx_insn *copy_of_b =3D as_a (copy_rtx (insn_b)); - rtx set =3D single_set (copy_of_b); + if (insn_b) + { + b =3D tmp_b ? tmp_b : gen_reg_rtx (GET_MODE (b)); + rtx_insn *copy_of_b =3D as_a (copy_rtx (insn_b)); + rtx set =3D single_set (copy_of_b); =20 - SET_DEST (set) =3D b; - emit_b =3D PATTERN (copy_of_b); + SET_DEST (set) =3D b; + emit_b =3D PATTERN (copy_of_b); + } + else + { + rtx tmp_reg =3D tmp_b ? tmp_b : gen_reg_rtx (GET_MODE (b)); + emit_b =3D gen_rtx_SET (tmp_reg, b); + b =3D tmp_reg; + } } } =20 @@ -2211,16 +2217,35 @@ noce_try_cmove_arith (struct noce_if_info *if_info) swap insn that sets up A with the one that sets up B. If even that doesn't help, punt. */ =20 - if (emit_a && modified_in_p (orig_b, emit_a)) - { - if (modified_in_p (orig_a, emit_b)) - goto end_seq_and_fail; + modified_in_a =3D emit_a !=3D NULL_RTX && modified_in_p (orig_b, emit_a); + if (tmp_b && then_bb) + { + FOR_BB_INSNS (then_bb, tmp_insn) + if (modified_in_p (orig_b, tmp_insn)) + { + modified_in_a =3D true; + break; + } =20 - if (else_bb && !b_simple) + } + if (emit_a && modified_in_a) + { + modified_in_b =3D emit_b !=3D NULL_RTX && modified_in_p (orig_a, emit_b); + if (tmp_b && else_bb) { - if (!noce_emit_bb (emit_b, else_bb, b_simple)) - goto end_seq_and_fail; + FOR_BB_INSNS (else_bb, tmp_insn) + if (modified_in_p (orig_a, tmp_insn)) + { + modified_in_b =3D true; + break; + } + } + if (modified_in_b) + goto end_seq_and_fail; + + if (!noce_emit_bb (emit_b, else_bb, b_simple)) + goto end_seq_and_fail; =20 if (!noce_emit_bb (emit_a, then_bb, a_simple)) goto end_seq_and_fail; --------------080101090807040306090902--