From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 57632 invoked by alias); 15 May 2017 17:07:29 -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 57596 invoked by uid 89); 15 May 2017 17:07:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,IMAGE_ATTACHED,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 May 2017 17:07:25 +0000 Received: by mail-wm0-f48.google.com with SMTP id v15so54906450wmv.1 for ; Mon, 15 May 2017 10:07:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=0OOYgPde681my3/FLzfNTRgLGRdw7GlOTJyO+tOGeZ8=; b=XG2AJsAQE+fOQK7RbIIoEwiPPe6D44RN1+IpYkVyfmj7JgNBP32c+wMEMU/NCAILPq sjt8VLL7YTmM7WofaUQBSVOFtaNQH0HihtNg8g7bPlGj8oLYljumOcH2jQgWHn0QHAQf J3MXfFYRADOmt6FROuQa6Bfcr5ohWOBZoeoPxMv3nLE6MOkSg3dr0mCc6UOWC7sKq9EX 53phcYp5keY/W9e45lFffJwL0o9pDedpUPR4QdlQlwklyKVTTJtxaXR9lilqOeH6ThdG fusoylfHeb/IlA9qObjP6E2dGgwcssUAvpRPetX6T9lkriV+8Vdz9D3R4XJ02khS5Gpt 1QdQ== X-Gm-Message-State: AODbwcDuB2/xpPBIblxvOPhwLqCPCahx7KaqzvRsLr/OuIECVPA2vjny WWc5F6iHq3YzejjR X-Received: by 10.28.14.205 with SMTP id 196mr4773203wmo.13.1494868046287; Mon, 15 May 2017 10:07:26 -0700 (PDT) Received: from [10.9.8.25] (14.27.187.81.in-addr.arpa. [81.187.27.14]) by smtp.gmail.com with ESMTPSA id 4sm18618580wrv.33.2017.05.15.10.07.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 May 2017 10:07:25 -0700 (PDT) Subject: Re: [PATCH] [ARC] Recognise add_n and sub_n in combine again To: Claudiu Zissulescu Cc: gcc-patches@gcc.gnu.org, Andrew Burgess , guybe@mellanox.com, noamca@mellanox.com References: <20170512191423.16256-1-graham.markall@embecosm.com> From: Graham Markall Message-ID: <4fbb6835-67bd-e597-8acb-5c3996d68139@embecosm.com> Date: Mon, 15 May 2017 17:22:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WcoJsHFLCg0RawIniMM9lHv3Lmc2EC2rr" X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg01202.txt.bz2 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WcoJsHFLCg0RawIniMM9lHv3Lmc2EC2rr Content-Type: multipart/mixed; boundary="G0k0aMqlq9I78PnGDK1djiBhtDuRFXKR9"; protected-headers="v1" From: Graham Markall To: Claudiu Zissulescu Cc: gcc-patches@gcc.gnu.org, Andrew Burgess , guybe@mellanox.com, noamca@mellanox.com Message-ID: <4fbb6835-67bd-e597-8acb-5c3996d68139@embecosm.com> Subject: Re: [PATCH] [ARC] Recognise add_n and sub_n in combine again References: <20170512191423.16256-1-graham.markall@embecosm.com> In-Reply-To: --G0k0aMqlq9I78PnGDK1djiBhtDuRFXKR9 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Content-length: 8919 Hi Claudiu, I ran the gcc testsuite with EZsim for NPS-400: $ ./EZsim_linux_x86_64 --version NPS-400 EZsim - Version 1.9a ( 35b02d7, Nov 3 2015, 20:14:04 ) both with and without the patch, and it did not introduce any new failures. Best regards, Graham. On 15/05/17 17:48, Claudiu Zissulescu wrote: > Hi Graham, >=20 > May I ask if you tested this with gcc's dejagnu? >=20 > Thanks, > Claudiu >=20 > On Fri, May 12, 2017 at 9:14 PM, Graham Markall > wrote: >> Since the combine pass canonicalises shift-add insns using plus and >> ashift (as opposed to plus and mult which it previously used to do), it >> no longer creates *add_n or *sub_n insns, as the patterns match plus and >> mult only. The outcome of this is that some opportunities to generate >> add{1,2,3} and sub{1,2,3} instructions are missed. >> >> This change adds additional *add_n and *sub_n insns that match the >> plus-ashift pattern. The original *add_n and *sub_n insns are still left >> in, as they are sometimes generated later on by constant propagation. >> The idea of adding these insns is modelled on the changes in: >> >> https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01882.html >> >> which addresses a similar issue for the PA target. >> >> For the small test cases that are added, even if the combine pass misses >> the opportunity to generate addN or subN, constant propagation manages >> to do so, so the rtl of the combine pass is checked. >> >> gcc/ChangeLog: >> >> * config/arc/arc.c (arc_print_operand): Handle constant operands. >> (arc_rtx_costs): Add costs for new patterns. >> * config/arc/arc.md: Additional *add_n and *sub_n patterns. >> * config/arc/predicates.md: Add _1_2_3_operand predicate. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.target/arc/add_n-combine.c: New. >> * gcc.target/arc/sub_n-combine.c: New. >> --- >> gcc/ChangeLog | 7 ++++ >> gcc/config/arc/arc.c | 20 +++++++++--- >> gcc/config/arc/arc.md | 26 +++++++++++++++ >> gcc/config/arc/predicates.md | 5 +++ >> gcc/testsuite/ChangeLog | 5 +++ >> gcc/testsuite/gcc.target/arc/add_n-combine.c | 48 +++++++++++++++++++++= +++++++ >> gcc/testsuite/gcc.target/arc/sub_n-combine.c | 21 ++++++++++++ >> 7 files changed, 128 insertions(+), 4 deletions(-) >> create mode 100644 gcc/testsuite/gcc.target/arc/add_n-combine.c >> create mode 100644 gcc/testsuite/gcc.target/arc/sub_n-combine.c >> >> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c >> index 91c28e7..42730d5 100644 >> --- a/gcc/config/arc/arc.c >> +++ b/gcc/config/arc/arc.c >> @@ -3483,6 +3483,14 @@ arc_print_operand (FILE *file, rtx x, int code) >> >> return; >> >> + case 'c': >> + if (GET_CODE (x) =3D=3D CONST_INT) >> + fprintf (file, "%d", INTVAL (x) ); >> + else >> + output_operand_lossage ("invalid operands to %%c code"); >> + >> + return; >> + >> case 'M': >> if (GET_CODE (x) =3D=3D CONST_INT) >> fprintf (file, "%d",exact_log2(~INTVAL (x)) ); >> @@ -4895,8 +4903,10 @@ arc_rtx_costs (rtx x, machine_mode mode, int oute= r_code, >> *total =3D COSTS_N_INSNS (2); >> return false; >> case PLUS: >> - if (GET_CODE (XEXP (x, 0)) =3D=3D MULT >> - && _2_4_8_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) >> + if ((GET_CODE (XEXP (x, 0)) =3D=3D ASHIFT >> + && _1_2_3_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) >> + || (GET_CODE (XEXP (x, 0)) =3D=3D MULT >> + && _2_4_8_operand (XEXP (XEXP (x, 0), 1), VOIDmode))) >> { >> *total +=3D (rtx_cost (XEXP (x, 1), mode, PLUS, 0, speed) >> + rtx_cost (XEXP (XEXP (x, 0), 0), mode, PLUS, 1, s= peed)); >> @@ -4904,8 +4914,10 @@ arc_rtx_costs (rtx x, machine_mode mode, int oute= r_code, >> } >> return false; >> case MINUS: >> - if (GET_CODE (XEXP (x, 1)) =3D=3D MULT >> - && _2_4_8_operand (XEXP (XEXP (x, 1), 1), VOIDmode)) >> + if ((GET_CODE (XEXP (x, 1)) =3D=3D ASHIFT >> + && _1_2_3_operand (XEXP (XEXP (x, 1), 1), VOIDmode)) >> + || (GET_CODE (XEXP (x, 1)) =3D=3D MULT >> + && _2_4_8_operand (XEXP (XEXP (x, 1), 1), VOIDmode))) >> { >> *total +=3D (rtx_cost (XEXP (x, 0), mode, PLUS, 0, speed) >> + rtx_cost (XEXP (XEXP (x, 1), 0), mode, PLUS, 1, s= peed)); >> diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md >> index edb983f..ec783a0 100644 >> --- a/gcc/config/arc/arc.md >> +++ b/gcc/config/arc/arc.md >> @@ -2995,6 +2995,19 @@ >> >> (define_insn "*add_n" >> [(set (match_operand:SI 0 "dest_reg_operand" "=3DRcqq,Rcw,W,W,w,w") >> + (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "Rcqq= ,c,c,c,c,c") >> + (match_operand:SI 2 "_1_2_3_operand" "")) >> + (match_operand:SI 3 "nonmemory_operand" "0,0,c,?Cal,?c,= ??Cal")))] >> + "" >> + "add%c2%? %0,%3,%1%&" >> + [(set_attr "type" "shift") >> + (set_attr "length" "*,4,4,8,4,8") >> + (set_attr "predicable" "yes,yes,no,no,no,no") >> + (set_attr "cond" "canuse,canuse,nocond,nocond,nocond,nocond") >> + (set_attr "iscompact" "maybe,false,false,false,false,false")]) >> + >> +(define_insn "*add_n" >> + [(set (match_operand:SI 0 "dest_reg_operand" "=3DRcqq,Rcw,W,W,w,w") >> (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "Rcqq,c= ,c,c,c,c") >> (match_operand:SI 2 "_2_4_8_operand" "")) >> (match_operand:SI 3 "nonmemory_operand" "0,0,c,?Cal,?c,= ??Cal")))] >> @@ -3011,6 +3024,19 @@ >> (define_insn "*sub_n" >> [(set (match_operand:SI 0 "dest_reg_operand" "=3DRcw,w,w") >> (minus:SI (match_operand:SI 1 "nonmemory_operand" "0,c,?Cal") >> + (ashift:SI (match_operand:SI 2 "register_operand" "c,c= ,c") >> + (match_operand:SI 3 "_1_2_3_operand" ""))))] >> + "" >> + "sub%c3%? %0,%1,%2" >> + [(set_attr "type" "shift") >> + (set_attr "length" "4,4,8") >> + (set_attr "predicable" "yes,no,no") >> + (set_attr "cond" "canuse,nocond,nocond") >> + (set_attr "iscompact" "false")]) >> + >> +(define_insn "*sub_n" >> + [(set (match_operand:SI 0 "dest_reg_operand" "=3DRcw,w,w") >> + (minus:SI (match_operand:SI 1 "nonmemory_operand" "0,c,?Cal") >> (mult:SI (match_operand:SI 2 "register_operand" "c,c,c= ") >> (match_operand:SI 3 "_2_4_8_operand" ""))))] >> "" >> diff --git a/gcc/config/arc/predicates.md b/gcc/config/arc/predicates.md >> index 7ddec91..1f66438 100644 >> --- a/gcc/config/arc/predicates.md >> +++ b/gcc/config/arc/predicates.md >> @@ -615,6 +615,11 @@ >> (match_test "TARGET_ARC700 || TARGET_EA_SET"))) >> ) >> >> +(define_predicate "_1_2_3_operand" >> + (and (match_code "const_int") >> + (match_test "INTVAL (op) =3D=3D 1 || INTVAL (op) =3D=3D 2 || INT= VAL (op) =3D=3D 3")) >> +) >> + >> (define_predicate "_2_4_8_operand" >> (and (match_code "const_int") >> (match_test "INTVAL (op) =3D=3D 2 || INTVAL (op) =3D=3D 4 || INT= VAL (op) =3D=3D 8")) >> diff --git a/gcc/testsuite/gcc.target/arc/add_n-combine.c b/gcc/testsuit= e/gcc.target/arc/add_n-combine.c >> new file mode 100644 >> index 0000000..db6454f >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/arc/add_n-combine.c >> @@ -0,0 +1,48 @@ >> +/* { dg-do compile } */ >> +/* { dg-options "-O2 -fdump-rtl-combine" } */ >> + >> +struct b1 { >> + char c; >> + char bg; >> +}; >> + >> +struct bj1 { >> + char bk; >> + struct b1 bn[]; >> +}; >> + >> +struct b2 { >> + short c; >> + char bg; >> +}; >> + >> +struct bj2 { >> + short bk; >> + struct b2 bn[]; >> +}; >> + >> +struct b3 { >> + int c; >> + char bg; >> +}; >> + >> +struct bj3 { >> + int bk; >> + struct b3 bn[]; >> +}; >> + >> + >> +struct bj1 at1; >> +struct bj2 at2; >> +struct bj3 at3; >> + >> +int bu; >> +void a(); >> + >> +void f() { >> + a(at1.bn[bu]); >> + a(at2.bn[bu]); >> + a(at3.bn[bu]); >> +} >> + >> +/* { dg-final { scan-rtl-dump-times "\\*add_n" 3 "combine" } } */ >> diff --git a/gcc/testsuite/gcc.target/arc/sub_n-combine.c b/gcc/testsuit= e/gcc.target/arc/sub_n-combine.c >> new file mode 100644 >> index 0000000..4e227e4 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/arc/sub_n-combine.c >> @@ -0,0 +1,21 @@ >> +/* { dg-do compile } */ >> +/* { dg-options "-O2 -fdump-rtl-combine" } */ >> + >> +int a; >> + >> +double b1() { >> + int c =3D a << 1; >> + return 1 - c; >> +} >> + >> +double b2() { >> + int c =3D a << 2; >> + return 1 - c; >> +} >> + >> +double b3() { >> + int c =3D a << 3; >> + return 1 - c; >> +} >> + >> +/* { dg-final { scan-rtl-dump-times "\\*sub_n" 3 "combine" } } */ >> -- >> 2.9.3 >> --G0k0aMqlq9I78PnGDK1djiBhtDuRFXKR9-- --WcoJsHFLCg0RawIniMM9lHv3Lmc2EC2rr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 473 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJZGeBJAAoJEO+WRZFire0WJAEH/02nVc4gPybZRrsmvoTmu6b6 DrJAaNkXry6p1lfE+cIzUar+IJEy5jnKhJZyDrOxiMxz7th+E98mETYaS0Kif9pi OwvVWgl60wChW0TJo9i4/pOBAmb52owQqbVHG1j0/GOOdQRXOJoPs3OntHRLlnSY tGlKxUKtMvK84P6Qz/s1goQCDmuNHX04xIJ9BGLNh4KkmwSOYHbea38E4VXUaBsO sUSF4kgNMYp1s3a0+MpOASh4XZpdCZjMFH9GTsctCtAcftXghmW3FiqiqYociZfP nhpKqDkkqaFsF25pwNN2yOXCHMziGo7ebkQrPHsFNktrbhsm15hv67pVkfGlK/8= =ErEq -----END PGP SIGNATURE----- --WcoJsHFLCg0RawIniMM9lHv3Lmc2EC2rr--