From patchwork Thu Dec 20 18:11:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1016908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-492912-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cq/XaUoP"; dkim-atps=neutral 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 43LKZl2zd9z9sC7 for ; Fri, 21 Dec 2018 05:11:26 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=EOGdDF+FJcpNRGU268FhipI9VGCxZDi9tz9Q65f55dbfp2OQsj p36jXdJcxRDFOohLt4ZL09rkKDYFIXndVYk4/LWabhdoEM3D4oXBFlscVGIZa05i LoNtYA0q0BU2S/adxdnJDP32qazayF0GQ4gXAbV2JY3fnxF5LOoVCAkdA= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=L+KDUMmqdhqUo/RIyVZe4I7EbTQ=; b=cq/XaUoPRLYSezU74aZ1 IOJZYq75h0swj8AiYn3KPsuhBH7V1o8rScJhdqQz3nm47NXuZrxhmhYmdq4/c9ok wAyx5LQzz5kHP3jgOsks6CVjzCbcqaj95n4QdW6JXUep74l2x4f1dYqzESCSTy5y h/afnjjtrbyKuzW3j0goQrg= Received: (qmail 118568 invoked by alias); 20 Dec 2018 18:11:19 -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 117594 invoked by uid 89); 20 Dec 2018 18:11:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Dec 2018 18:11:16 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EE4E390EA for ; Thu, 20 Dec 2018 18:11:15 +0000 (UTC) Received: from tobol.usersys.redhat.com (unused-10-15-17-174.yyz.redhat.com [10.15.17.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EB6D1001F3C for ; Thu, 20 Dec 2018 18:11:15 +0000 (UTC) To: gcc-patches From: Vladimir Makarov Subject: patch to fix PR88457 Message-ID: <21b587bd-347d-f67e-d07d-33cb753aa8a0@redhat.com> Date: Thu, 20 Dec 2018 13:11:14 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88457   The patch was successfully bootstrapped and tested on x86-64 and ppc64.   Committed as rev. 267307 Index: ChangeLog =================================================================== --- ChangeLog (revision 267306) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2018-12-20 Vladimir Makarov + + PR target/88457 + * ira-color.c (fast_allocation): Choose the best cost hard reg. + 2018-12-20 Richard Sandiford * config/aarch64/iterators.md (SVE_INT_UNARY, fp_int_op): Add abs. Index: ira-color.c =================================================================== --- ira-color.c (revision 267245) +++ ira-color.c (working copy) @@ -4852,7 +4852,8 @@ color (void) static void fast_allocation (void) { - int i, j, k, num, class_size, hard_regno; + int i, j, k, num, class_size, hard_regno, best_hard_regno, cost, min_cost; + int *costs; #ifdef STACK_REGS bool no_stack_reg_p; #endif @@ -4903,6 +4904,9 @@ fast_allocation (void) no_stack_reg_p = ALLOCNO_NO_STACK_REG_P (a); #endif class_size = ira_class_hard_regs_num[aclass]; + costs = ALLOCNO_HARD_REG_COSTS (a); + min_cost = INT_MAX; + best_hard_regno = -1; for (j = 0; j < class_size; j++) { hard_regno = ira_class_hard_regs[aclass][j]; @@ -4915,16 +4919,28 @@ fast_allocation (void) || (TEST_HARD_REG_BIT (ira_prohibited_class_mode_regs[aclass][mode], hard_regno))) continue; - ALLOCNO_HARD_REGNO (a) = hard_regno; - for (l = 0; l < nr; l++) + if (costs == NULL) { - ira_object_t obj = ALLOCNO_OBJECT (a, l); - for (r = OBJECT_LIVE_RANGES (obj); r != NULL; r = r->next) - for (k = r->start; k <= r->finish; k++) - IOR_HARD_REG_SET (used_hard_regs[k], - ira_reg_mode_hard_regset[hard_regno][mode]); + best_hard_regno = hard_regno; + break; } - break; + cost = costs[j]; + if (min_cost > cost) + { + min_cost = cost; + best_hard_regno = hard_regno; + } + } + if (best_hard_regno < 0) + continue; + ALLOCNO_HARD_REGNO (a) = hard_regno = best_hard_regno; + for (l = 0; l < nr; l++) + { + ira_object_t obj = ALLOCNO_OBJECT (a, l); + for (r = OBJECT_LIVE_RANGES (obj); r != NULL; r = r->next) + for (k = r->start; k <= r->finish; k++) + IOR_HARD_REG_SET (used_hard_regs[k], + ira_reg_mode_hard_regset[hard_regno][mode]); } } ira_free (sorted_allocnos); Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 267306) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2018-12-20 Vladimir Makarov + + PR target/88457 + * gcc.target/powerpc/pr88457.c: New. + 2018-12-20 Jakub Jelinek PR c++/88180 Index: testsuite/gcc.target/powerpc/pr88457.c =================================================================== --- testsuite/gcc.target/powerpc/pr88457.c (revision 0) +++ testsuite/gcc.target/powerpc/pr88457.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-options "-m32 -mcpu=power7 -O1 -fexpensive-optimizations --param ira-max-conflict-table-size=0 --param max-cse-insns=3 -c -mcpu=e300c3" } */ + +__attribute__((target_clones("cpu=power9,default"))) +long mod_func (long a, long b) +{ + return a % b; +} + +long mod_func_or (long a, long b, long c) +{ + return mod_func (a, b) | c; +}