From patchwork Fri Oct 21 10:46:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 685021 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 3t0j7d6Dwdz9sCZ for ; Fri, 21 Oct 2016 21:47:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=gDhL5rTM; 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 :references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; q=dns; s=default; b=uWeX8pCtjreBEkDm ICKxVHlHSNRXcNlYxqH6InU8z0JD5MjDVZeb9ZU9fpJGeAtd9lV87Ksr0zHWq7oR l2JlDd4wGc8xAbmLEN2fWg/fF4yvz/ULvjHG8HDyz6/9fRmgBsJuMD5hBPyHiLBq cjkPSSP5Ajep2Hp+2FBpYtZW2Lc= 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 :references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; s=default; bh=R7DjA/fdFfggUNfaldFZd9 xqvOQ=; b=gDhL5rTM5QbYj8+rGZ2qc8S0V23cc63q3JmTrtmI5DeSHqVjCuAFdv Ca5PHpK+FEjM71fQsSSKw1JyA7fDPjviCLrfcGAxQzKACNwyqzN8JIwjX+pfoNYh +fA+ZTTJsJ6tBYwJcpVANUpUgywy0/fdpG/t/sDldI27gm1uvRwHM= Received: (qmail 111480 invoked by alias); 21 Oct 2016 10:47:49 -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 111470 invoked by uid 89); 21 Oct 2016 10:47:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=BAYES_20, RCVD_IN_BRBL_LASTEXT, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 spammy=H*r:Fri, Hx-languages-length:2587, HX-HELO:sk:eusmtp0, H*r:ip*10.145.145.30 X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.242) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Oct 2016 10:47:38 +0000 Received: from HNOCHT01.corp.atmel.com (10.145.133.40) by eusmtp01.atmel.com (10.145.145.30) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 21 Oct 2016 12:47:28 +0200 Received: from jaguar.atmel.com (10.145.133.18) by HNOCHT01.corp.atmel.com (10.145.133.40) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 21 Oct 2016 12:47:33 +0200 References: <87lgyris6r.fsf@atmel.com> <1a0d4ad7-6d88-ab84-5bd1-71edf931686e@redhat.com> <871szkg2he.fsf@atmel.com> <87eg3dkg4p.fsf@atmel.com> <5580f882-8be4-2b0c-530f-f2fec34fdf04@redhat.com> User-agent: mu4e 0.9.17; emacs 24.5.1 From: Senthil Kumar Selvaraj To: Bernd Schmidt CC: gcc Patches Subject: Re: [Patch, reload, tentative, PR 71627] Tweak conditions in find_valid_class_1 In-Reply-To: <5580f882-8be4-2b0c-530f-f2fec34fdf04@redhat.com> Date: Fri, 21 Oct 2016 16:16:19 +0530 Message-ID: <87bmyej7yc.fsf@atmel.com> MIME-Version: 1.0 X-IsSubscribed: yes Bernd Schmidt writes: > On 10/18/2016 02:15 PM, Senthil Kumar Selvaraj wrote: >> Will do both the changes and re-run the reg tests. Ok for trunk if the >> tests pass for x86_64-pc-linux and avr? >> > Probably but let's see the patch first. How does this look? Bootstrapped and reg tested x86_64-pc-linux on top of trunk@190252 with the in_hard_reg_set_p patch backport - there were no failures. Also ran regtests for avr on trunk, no failures there as well. Ok to commit to trunk? Regards Senthil gcc/ChangeLog: 2016-10-21 Senthil Kumar Selvaraj * reload.c (find_valid_class_1): Allow regclass if atleast one regno in class is ok. Compute and use rclass size based on actually available regnos for mode in rclass. gcc/testsuite/ChangeLog: 2016-10-21 Senthil Kumar Selvaraj * gcc.target/avr/pr71627.c: New test. diff --git gcc/reload.c gcc/reload.c index 9a859e5..880099e 100644 --- gcc/reload.c +++ gcc/reload.c @@ -715,25 +715,23 @@ find_valid_class_1 (machine_mode outer ATTRIBUTE_UNUSED, for (rclass = 1; rclass < N_REG_CLASSES; rclass++) { - int bad = 0; - for (regno = 0; regno < FIRST_PSEUDO_REGISTER && !bad; regno++) - { - if (in_hard_reg_set_p (reg_class_contents[rclass], mode, regno) - && !HARD_REGNO_MODE_OK (regno, mode)) - bad = 1; - } - - if (bad) - continue; + unsigned int computed_rclass_size = 0; + + for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) + { + if (in_hard_reg_set_p (reg_class_contents[rclass], mode, regno) + && (HARD_REGNO_MODE_OK (regno, mode))) + computed_rclass_size++; + } cost = register_move_cost (outer, (enum reg_class) rclass, dest_class); - if ((reg_class_size[rclass] > best_size + if ((computed_rclass_size > best_size && (best_cost < 0 || best_cost >= cost)) || best_cost > cost) { best_class = (enum reg_class) rclass; - best_size = reg_class_size[rclass]; + best_size = computed_rclass_size; best_cost = register_move_cost (outer, (enum reg_class) rclass, dest_class); } diff --git gcc/testsuite/gcc.target/avr/pr71627.c gcc/testsuite/gcc.target/avr/pr71627.c new file mode 100644 index 0000000..eaef3d2 --- /dev/null +++ gcc/testsuite/gcc.target/avr/pr71627.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + + +extern volatile __memx const long a, b, c, d, e, f; +extern volatile long result; + +extern void vfunc (const char*, ...); + +void foo (void) +{ + result = a + b + c + d + e + f; + vfunc ("text", a, b, c, d, e, f, result); +}