From patchwork Wed Jan 15 00:09:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 310909 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 4069D2C0082 for ; Wed, 15 Jan 2014 11:09:15 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=ABE2ZuzwNWQ2BsUYaIZ56FRQeylq8hjm044bDj7OmBo1Yw 2pMobYRkgGsEbGf2ICnCRspAyLDkr7ko6kweHm+hYYOWhsJW+o24rm6FJyWZoIuc pdb5GsHwn3uWDdYZ/6LP8/wlrgsi0+B4cWlyNoEV/1BEYEfxWwViqlw1g/tI4= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=1+jVNTA6yKLxhp7fY+MYmwBDZnQ=; b=tlNCwMqMfNxR7wMc4LgD MPPCv4pGfbu1JrngspyAv8l1eB6H+RX4qSFhOPgIeA6bO56KD2klJYbe5kLL0O3e DHyUSpKRmyfHJZ1mv9z9nhxZHOcAdyXfFMsQvfUQt9Fq+q+DjS0R3C/CWItATSMO jE7maB5KlHqoOhYbmFlR29E= Received: (qmail 25650 invoked by alias); 15 Jan 2014 00:09:07 -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 25632 invoked by uid 89); 15 Jan 2014 00:09:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vb0-f54.google.com Received: from mail-vb0-f54.google.com (HELO mail-vb0-f54.google.com) (209.85.212.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 15 Jan 2014 00:09:05 +0000 Received: by mail-vb0-f54.google.com with SMTP id w20so133572vbb.13 for ; Tue, 14 Jan 2014 16:09:03 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.220.106.84 with SMTP id w20mr2012530vco.18.1389744543521; Tue, 14 Jan 2014 16:09:03 -0800 (PST) Received: by 10.58.178.207 with HTTP; Tue, 14 Jan 2014 16:09:03 -0800 (PST) Date: Tue, 14 Jan 2014 16:09:03 -0800 Message-ID: Subject: [PATCH/AARCH64] Fix register cost for moving to/from stack registers From: Andrew Pinski To: GCC Patches X-IsSubscribed: yes While writing the Thunder tunings, I got an internal compiler error while building glibc. The reduced testcase is: typedef unsigned int size_t; typedef unsigned int wchar_t; extern __thread int __libc_errno; extern __thread int * t; int _IO_vfprintf_internal (char *string, char *workend, char *f) { int save_errno = __libc_errno; do { int prec = (workend - string); string = (char *) __strerror_r (save_errno); if ( *t == 1) { size_t ignore_size = (unsigned) prec > 1024 ? 1024 : prec; wchar_t ignore[ignore_size]; const char *str2 = string; const char *strend = string + prec; int ps; while (str2 != ((void *)0) && str2 < strend) __mbsnrtowcs (ignore, &str2 ,&ps) ; } } while (*f != '\0'); } ---- CUT --- I changed the cost of moving between two neon registers (FP_REGS register class) to be the same as the cost of moving between a GENERAL_REGS and a FP_REGS class. This caused the cost of moving between the STACK_REG and FP_REGS being the same FP_REGS and GENERAL_REGS which is incorrect as it has to go through a GENERAL_REGS. This patch fixes the problem by changing the cost of the move between STACK_REG and FP_REGS to the cost of moving via a GENERAL_REGS. OK? Built and tested on aarch64-elf with no regressions. Thanks, Andrew Pinski ChangeLog: * config/aarch64/aarch64.c (aarch64_register_move_cost): Correct cost of moving from/to the STACK_REG register class. Index: config/aarch64/aarch64.c =================================================================== --- config/aarch64/aarch64.c (revision 206611) +++ config/aarch64/aarch64.c (working copy) @@ -4870,6 +4870,16 @@ aarch64_register_move_cost (enum machine const struct cpu_regmove_cost *regmove_cost = aarch64_tune_params->regmove_cost; + /* Moving between GPR and stack cost is the same as GP2GP. */ + if ((from == GENERAL_REGS && to == STACK_REG) + || (to == GENERAL_REGS && from == STACK_REG)) + return regmove_cost->GP2GP; + + /* To/From the stack register, is the move via the gprs. */ + if (to == STACK_REG || from == STACK_REG) + return aarch64_register_move_cost (mode, from, GENERAL_REGS) + + aarch64_register_move_cost (mode, GENERAL_REGS, to); + if (from == GENERAL_REGS && to == GENERAL_REGS) return regmove_cost->GP2GP; else if (from == GENERAL_REGS)