From patchwork Thu Oct 13 06:57:49 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: 681633 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 3svhRj09qDz9snm for ; Thu, 13 Oct 2016 17:59:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=H87SeTdQ; 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=AS5OuaiEEuSS5Qu3 z7Otta9NsKOO4zqxaoH11d1+y0nrB6OtTb+4y4da42KXd8SGTNb6azznbXWqZsgh Y1vGg7NJLgMiNAQgv2HHiVA60eqbjIXSubtjwry6fV+RZDW5I8CprM52N+Vxzn16 hu40oDGKn0YS6ti0EQ0I7xA0tuI= 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=PJ6WcAkztQYgeSN6CrsZEI Zw1Tk=; b=H87SeTdQ08EmJgvu6lRJn2GO9MihRyEWmgPEiOpijAxYrEVbPJHlem S21RhZWFnLnDjaSIpaE49OkCJrzpJbSxqfhig+vg9KIPdC2pMLRRZMYEsCN3ENTk vFkwarBJTgIc4qDDL9imDXaKI1PplFpPiK1SBfW1L8Wy7PCAmFeqs= Received: (qmail 104584 invoked by alias); 13 Oct 2016 06:59:17 -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 104561 invoked by uid 89); 13 Oct 2016 06:59:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 spammy=You'll, H*r:Thu, adapted, reloadc X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.243) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Oct 2016 06:59:06 +0000 Received: from HNOCHT02.corp.atmel.com (10.145.133.41) by eusmtp01.atmel.com (10.145.145.31) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 13 Oct 2016 08:58:58 +0200 Received: from jaguar.atmel.com (10.145.133.18) by HNOCHT02.corp.atmel.com (10.145.133.41) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 13 Oct 2016 08:59:01 +0200 References: <87lgyris6r.fsf@atmel.com> <1a0d4ad7-6d88-ab84-5bd1-71edf931686e@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: <1a0d4ad7-6d88-ab84-5bd1-71edf931686e@redhat.com> Date: Thu, 13 Oct 2016 12:27:49 +0530 Message-ID: <871szkg2he.fsf@atmel.com> MIME-Version: 1.0 X-IsSubscribed: yes Bernd Schmidt writes: > On 09/16/2016 09:02 PM, Senthil Kumar Selvaraj wrote: >> Does this make sense? I ran a reg test for the avr target with a >> slightly older version of this patch, it did not show any regressions. >> If this is the right fix, I'll make sure to run reg tests on x86_64 >> after backporting to a gcc version where that target used reload. > > It's hard to say, and could have different effects on different targets. > One thing though, at the very least the reg_class_size test would have > to be adapted - the idea is to find the largest class, and there's a > risk here of ending up with a large class that only has one valid register. Agreed - I've updated the patch to compute rclass sizes based on regno availability i.e., only if in_hard_reg_set_p and HARD_REGNO_MODE_OK, and then use the computed sizes when calculating best_size. > > You'll also want to verify this against > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54814 Yes, this patch doesn't break the fix for PR54814. The change to in_hard_reg_set_p was what fixed that, and that remains unmodified. Reg tested this on top of trunk@190252 with the in_hard_reg_set_p backport. x86_64-pc-linux bootstrapped and regtested ok. avr showed no regressions either. Ok for trunk? Regards Senthil gcc/ChangeLog: 2016-10-13 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-13 Senthil Kumar Selvaraj * gcc.target/avr/pr71627.c: New. Index: gcc/reload.c =================================================================== --- gcc/reload.c (revision 240989) +++ gcc/reload.c (working copy) @@ -711,31 +711,36 @@ enum reg_class best_class = NO_REGS; unsigned int best_size = 0; int cost; + unsigned int computed_rclass_sizes[N_REG_CLASSES] = { 0 }; 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; + int atleast_one_regno_ok = 0; + for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) + { + if (in_hard_reg_set_p (reg_class_contents[rclass], mode, regno)) + { + atleast_one_regno_ok = 1; + if (HARD_REGNO_MODE_OK (regno, mode)) + computed_rclass_sizes[rclass]++; + } + } + + if (!atleast_one_regno_ok) + continue; + cost = register_move_cost (outer, (enum reg_class) rclass, dest_class); - if ((reg_class_size[rclass] > best_size - && (best_cost < 0 || best_cost >= cost)) - || best_cost > cost) - { - best_class = (enum reg_class) rclass; - best_size = reg_class_size[rclass]; - best_cost = register_move_cost (outer, (enum reg_class) rclass, - dest_class); - } + if ((computed_rclass_sizes[rclass] > best_size + && (best_cost < 0 || best_cost >= cost)) + || best_cost > cost) + { + best_class = (enum reg_class) rclass; + best_size = computed_rclass_sizes[rclass]; + best_cost = register_move_cost (outer, (enum reg_class) rclass, + dest_class); + } } gcc_assert (best_size != 0); Index: gcc/testsuite/gcc.target/avr/pr71627.c =================================================================== --- gcc/testsuite/gcc.target/avr/pr71627.c (nonexistent) +++ gcc/testsuite/gcc.target/avr/pr71627.c (working copy) @@ -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); +}