From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91568 invoked by alias); 2 Jun 2017 14:02:59 -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 91548 invoked by uid 89); 2 Jun 2017 14:02:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LOTSOFHASH,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4323 X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0058.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Jun 2017 14:02:55 +0000 Received: from DB5PR08CA0063.eurprd08.prod.outlook.com (2a01:111:e400:c576::31) by VI1PR0801MB2015.eurprd08.prod.outlook.com (2603:10a6:800:8b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Fri, 2 Jun 2017 14:02:56 +0000 Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::201) by DB5PR08CA0063.outlook.office365.com (2a01:111:e400:c576::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10 via Frontend Transport; Fri, 2 Jun 2017 14:02:55 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1101.12 via Frontend Transport; Fri, 2 Jun 2017 14:02:55 +0000 Received: from arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.294.0; Fri, 2 Jun 2017 15:02:46 +0100 Date: Fri, 02 Jun 2017 14:02:00 -0000 From: James Greenhalgh To: Kyrill Tkachov CC: GCC Patches , Marcus Shawcroft , Richard Earnshaw , Subject: Re: [PATCH][AArch64] Use SUBS for parallel subtraction and comparison with immediate Message-ID: <20170602140246.GC39371@arm.com> References: <58F9C0E7.4070600@foss.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <58F9C0E7.4070600@foss.arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140;IPV:CAL;SCL:-1;CTRY:GB;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39400400002)(39860400002)(39450400003)(39410400002)(39850400002)(39840400002)(2980300002)(438002)(53754006)(377424004)(199003)(189002)(24454002)(6246003)(575784001)(86362001)(97756001)(4326008)(305945005)(36756003)(6862004)(8936002)(106466001)(8676002)(189998001)(4001350100001)(23726003)(6286002)(356003)(54906002)(1076002)(33656002)(55016002)(50466002)(47776003)(104016004)(110136004)(38730400002)(2950100002)(77096006)(2906002)(50986999)(229853002)(54356999)(76176999)(5660300001)(72206003)(7696004)(478600001)(83506001)(14773001)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0801MB2015;H:nebula.arm.com;FPR:;SPF:Pass;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DB5EUR03FT008;1:1ozb09Xe8/SQX8T8QEMvc5P9dP2BhGEjMF+36caNdGxkHyQwXGwaThAVYGK2yTUJ7DNXqwBVlogsGnZH2ver79267j2T6vK4RYI1Ix1h3XBkfa5e0cpRKSFndkx0I+Cri/osNg3crS28zdRYbKz39H0sENI62HxceYtqDlBKtXo5qAwUesp8JQyRd3/qH/9f3YNu7vSZvjqxB4yt3Va0r0uIdADJtz/sso+y/DtMyrjD2B5VAEEs2t2bkW4Vwv8v33g2AG1rPGWcudA7d3BsYOJL+xAgZMksHi1XkC2XM1LNVHNIol5oTvT7DTroq+WO8dSa1ZVEWal0ihq5DT8FAAtlVbMaYqQ2l1G0J0JaDUWFoOH7mjrCMTnaNMk/MUtHp+wWi1Xb8Tg+VBJBIoPDAqylMT/lPSDWUnMjsUrr6wBXeNiLPpRwBbsEPTjc+LdFEvQZZjFertpKQ/EPu5L1xdnvGi82M9t0g3z2JWE8d7Y3RJy14WJjN0ChHp+UDYjUJ23ti4J9ZKVr+oqccIEXw8yxlPKGxjfF2YnLqwLYT5r5ludniFXdDZ/4pypTA7gvDL+Ba7XyhSQfZRdZp4MhBw== X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0801MB2015: X-MS-Office365-Filtering-Correlation-Id: df9bc5ad-3379-48ab-e545-08d4a9c01147 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075);SRVR:VI1PR0801MB2015; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2015;3:8p75dTb5aqs57Fl+aNAdDebF5xPT+0VP4tS12kCEZR3WALHstHSnCKdTIkTApLia8rKMZgybyGMqDTj0LYP+7FHfJ+kzabDLWrtW8HMnM2C9X/A8ZbLbRGe/cjwKnzs+GogGuzlT3gJTepwiFo0sxDAJoF6eCx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+VjXMiY0JPsRFFYWtB83glDdn3FgqkuTg/308i36sCv4+s76NOnGUMuQTk8rGDGLxpcwa4A8VLw6V1IAeMzs7gVzUXc0F8eIulQnD6wBU5sf7PTLIy4mqAgs5g== NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2015;20:ulu1vBfldbWjDHgL1FdN2FXLxcIRu3UDWF54ixqGTgkbI/xA1fDY2yxNn4nDhPI/ne6uW9lGoWvcF1vCSG3zW/rX3RzzmZ7dGVFDQQDRhwnFvlZ+DuaP2DcakMfEPIrnTPWWF+YLiQMi33eZAHWEowNYP/SoX9TRzmmEO1KOwRQy6NTkRCsQoULTNEmjTHjustpHdkXwodhmq0x4qWA67evJJO/CbFzEwL42V6TIblxuVProAT3vq0tKPselcT5L X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(13013025)(13021025)(8121501046)(100000703101)(100105400095)(3002001)(93006095)(93004095)(10201501046)(6055026)(6041248)(20161123564025)(20161123560025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0801MB2015;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0801MB2015; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0801MB2015;4:j/nfrkbyL9eG13SK2fimguG0mpacl/alTQrUYSoj?= =?us-ascii?Q?NdjQ4r1LWWhGwop0iGEqe1hiY3jgZCXj4ujrOUmGDEcLDdGuamnY6HAEkc/K?= =?us-ascii?Q?6yfkvB/loX9ZvDpvSoVayqa36162L0FGA9vYvAPLf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miCjnQC7m2Xx/7c+0o//eYd9U5qzTs4GVAYc+Mh6s49qSsz?= =?us-ascii?Q?foxyWrV1vPfJ2f6fbiT/aAlSxcxw6zSHoFOVNLrsktotbkzoxYhdDm+fq3Bw?= =?us-ascii?Q?UBpSEnweyPzY6QY8tV6gPRQCvdPcCuGKRA5KVTE5SDS5qSAlqMU8VHLpsS50?= =?us-ascii?Q?VPgzJ+KrYeoWxdzLMryL/bUtKK7RwdfjSpNTMvHGtj0IaZjfqG486pak3h+f?= =?us-ascii?Q?0BD32c8iRy4WHrosrUE=3D?= X-Forefront-PRVS: 03264AEA72 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0801MB2015;23:k7YHOgLgsd4T9we6LaekedPXVvN28cy3D8kmgAe?= =?us-ascii?Q?q6YcZ6Zx24Sqfc7HJlZ31PT2x51vFhyZqkwFZIctD7RAUvlMPF/35MHoF79N?= =?us-ascii?Q?IhdPryDIXN7Pm/OfRf6Tkwk6VZ4vge7qTd3PcUYrg4tfSrBODDjHAAKbE6sl?= =?us-ascii?Q?uKindYGhlndjNaL1QFIN7NVHYDSN22ToWovtH5irsLcTNANRegcE2kZ9lBAL?= =?us-ascii?Q?dMEPL37jHhRsN+sd9dtqNKWhGlS5NoXTt3/+PYqH8hFNHEh8yBq1shJEZuJw?= =?us-ascii?Q?EZdkrAb+xI+Zi+R6ru9SnC16wBgNucEug+js6kXTQgO0VIkkjOeL7/v6Mhv1?= =?us-ascii?Q?Fhm8NAg4pIGKxJrKE6DvT8d0NcHuHLKcr3G1L0OMReO5u/OGmjRMKBkUHYBw?= =?us-ascii?Q?p3BDlnwkApODEuQub/isHCtoQKSFhfK5OQFyHuxWur80/u/dWzdF5OtnfrOm?= =?us-ascii?Q?uu55hG0ZoqcZ1HHGPc89U964VzHGyB2N3iSxg130a8pStVLz+ESIQpIBngv0?= =?us-ascii?Q?MSgrI9QJm5QEddn7TQ49RTbllrMV/PzP38PQ6r1nYUhmrZnEp+zSveZIrC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XjkNAUBFuS565qOaEko4s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2015;7:om4VGxC/8+zgzGuorooe1PCwBi1eIvkV8Q6s9CN6WHfvAXIMM7C0T21FIPvMrb/8Z7QEvrN0op7R+RYPodmDhZVy6IFG72EWMI9Pozq8aYhFaX8TSKyZ6YLDOpB4oaCo4Zl8owLpWIWU7PQm76n5luOkGDzCT5msPFa9hYL9RwT1r8NpBXr8F41N8m/cQgSb2o3LUrCqBeBnvJPYNwIU/HkRsGklS4lhXK2VhfQpMxHg9KxYkMixqbJ5ejwluKJ9bgyULcSx1unAgiqwv1tAjl7q4I5XPIKZSBm17iMX31gB44Kug1nwMAsKbUfI88XpQ/YVH9OhJuphGPSxuhMR2g== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2017 14:02:55.2478 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[217.140.96.140];Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2015 X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00131.txt.bz2 On Fri, Apr 21, 2017 at 09:20:55AM +0100, Kyrill Tkachov wrote: > Hi all, > > Our sub3_compare1 pattern is not enough to catch cases where we > subtract an immediate and compare against in PARALLEL. This is due to the RTL > canonicalisation rules that require subtractions of immediate IMM be > represented as (plus x -IMM). So we need a bit of trickery to catch those > cases and this patch does that. It adds a new define_insn to match the > plus-negatable-immediate in parallel with a comparison and a peephole that > will bring the two together when possible. Otherwise it's pretty > straightforward. > > The testcase in the patch now generates a single SUBS-immediate instead of a > SUB followed by a CMP. > > Bootstrapped and tested on aarch64-none-linux-gnu. > > Ok for GCC 8? OK. Thansk, James > > Thanks, > Kyrill > > 2017-04-21 Kyrylo Tkachov > > * config/aarch64/aarch64.md (sub3_compare1_imm): New define_insn. > (peephole2): New peephole2 to emit the above. > * config/aarch64/predicates.md (aarch64_sub_immediate): New predicate. > > 2017-04-21 Kyrylo Tkachov > > * gcc.target/aarch64/subs_compare_2.c: New test. > > diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md > index 2a0341e1a957ebd28bc9e29465803501be23cd72..ff34e0d5ff4713f7b8005855f62e834aceef51f0 100644 > --- a/gcc/config/aarch64/aarch64.md > +++ b/gcc/config/aarch64/aarch64.md > @@ -2344,6 +2344,19 @@ (define_insn "sub3_compare1" > [(set_attr "type" "alus_sreg")] > ) > > +(define_insn "sub3_compare1_imm" > + [(set (reg:CC CC_REGNUM) > + (compare:CC > + (match_operand:GPI 1 "register_operand" "r") > + (match_operand:GPI 3 "const_int_operand" "n"))) > + (set (match_operand:GPI 0 "register_operand" "=r") > + (plus:GPI (match_dup 1) > + (match_operand:GPI 2 "aarch64_sub_immediate" "J")))] > + "INTVAL (operands[3]) == -INTVAL (operands[2])" > + "subs\\t%0, %1, #%n2" > + [(set_attr "type" "alus_sreg")] > +) > + > (define_peephole2 > [(set (match_operand:GPI 0 "register_operand") > (minus:GPI (match_operand:GPI 1 "aarch64_reg_or_zero") > @@ -2362,6 +2375,24 @@ (define_peephole2 > } > ) > > +(define_peephole2 > + [(set (match_operand:GPI 0 "register_operand") > + (plus:GPI (match_operand:GPI 1 "register_operand") > + (match_operand:GPI 2 "aarch64_sub_immediate"))) > + (set (reg:CC CC_REGNUM) > + (compare:CC > + (match_dup 1) > + (match_operand:GPI 3 "const_int_operand")))] > + "!reg_overlap_mentioned_p (operands[0], operands[1]) > + && INTVAL (operands[3]) == -INTVAL (operands[2])" > + [(const_int 0)] > + { > + emit_insn (gen_sub3_compare1_imm (operands[0], operands[1], > + operands[2], operands[3])); > + DONE; > + } > +) > + > (define_insn "*sub__" > [(set (match_operand:GPI 0 "register_operand" "=r") > (minus:GPI (match_operand:GPI 3 "register_operand" "r") > diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md > index 875ae6180e232e25b29c8787c0acf7a5dfa82d94..4bd8f45562c017bca736ae466ede6b9e4de0d17a 100644 > --- a/gcc/config/aarch64/predicates.md > +++ b/gcc/config/aarch64/predicates.md > @@ -77,6 +77,10 @@ (define_predicate "aarch64_fp_pow2" > (define_predicate "aarch64_fp_vec_pow2" > (match_test "aarch64_vec_fpconst_pow_of_2 (op) > 0")) > > +(define_predicate "aarch64_sub_immediate" > + (and (match_code "const_int") > + (match_test "aarch64_uimm12_shift (-INTVAL (op))"))) > + > (define_predicate "aarch64_plus_immediate" > (and (match_code "const_int") > (ior (match_test "aarch64_uimm12_shift (INTVAL (op))") > diff --git a/gcc/testsuite/gcc.target/aarch64/subs_compare_2.c b/gcc/testsuite/gcc.target/aarch64/subs_compare_2.c > new file mode 100644 > index 0000000000000000000000000000000000000000..60c6d9e5ccd8fce42c388c831a8060dead128491 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/subs_compare_2.c > @@ -0,0 +1,15 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +int > +foo (int a, int b) > +{ > + int x = a - 4; > + if (a < 4) > + return x; > + else > + return 0; > +} > + > +/* { dg-final { scan-assembler-times "subs\\tw\[0-9\]+, w\[0-9\]+, #4" 1 } } */ > +/* { dg-final { scan-assembler-not "cmp\\tw\[0-9\]+, w\[0-9\]+" } } */