From patchwork Tue Sep 19 11:21:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 815464 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-462467-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OtvcGDab"; 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 3xxL723T0hz9s7B for ; Tue, 19 Sep 2017 21:21:49 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=jf+J2QLrIgp1OYr4GroEg/hjtGH/Z3cjtPD/g+fzo1b7slvpsO CaioeQagI1fTDSzWZTXxiAqfD0Nbua/uuSjRRIkmWYlJp5Iqbogx9gDItd9/JZPr QRWQ6MI1y47uvh7K5SY7xZIuxz04P4u9Qi7AFjYtA/j3Fa58xQO7Cp9yQ= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=3VymZlWbAaXkFgvtA4t6BNGoyEc=; b=OtvcGDabGUH9peWYBYsA SL1/zraXQWUpEW3+uDHL3n5Kd9X1kibJJUvLqTf92nvuYzqlKsEmHIYpRvh7P7UM +CU3LqBtDioPcK6AOLSzGm09+NS7WGbmBVnc0ufgzgBMbSILY4Hl6fWxiT+Z7KV2 9U3SMTdJJqKAAgYsPv8/8+I= Received: (qmail 58850 invoked by alias); 19 Sep 2017 11:21:39 -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 58516 invoked by uid 89); 19 Sep 2017 11:21:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*kyrylo.tkachov X-HELO: smtp.ispras.ru Received: from bran.ispras.ru (HELO smtp.ispras.ru) (83.149.199.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Sep 2017 11:21:37 +0000 Received: from monopod.intra.ispras.ru (monopod.intra.ispras.ru [10.10.3.121]) by smtp.ispras.ru (Postfix) with ESMTP id 18F81203CA; Tue, 19 Sep 2017 14:21:35 +0300 (MSK) Date: Tue, 19 Sep 2017 14:21:34 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org cc: Maxim Kuvyrkov , Kyrill Tkachov Subject: [PATCH] haifa-sched: fix autopref_rank_for_schedule qsort comparator Message-ID: User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) MIME-Version: 1.0 Hello, The autopref_rank_for_schedule qsort sub-comparator is not actually a proper comparator. For instance, it lacks transitivity: if there's insns A, B, C such that B has AUTOPREF_MULTUPASS_DATA_IRRELEVANT status, but A and C compare such that C < A, we can have A == B == C < A according to this sub-comparator, and A < B < C < A if the following tie-breakers order A before B and B before C. I'm not sure this heuristic fits well into the overall scheduler sorting, but if we want to just fix this comparison step, we should never skip calls to autopref_rank_data. Bootstrapped and regtested on x86-64 with PARAM_SCHED_AUTOPREF_QUEUE_DEPTH set to '0' (otherwise this sub-comparator is unused). OK to apply? Thanks. Alexander * haifa-sched.c (autopref_rank_for_schedule): Always invoke autopref_rank_data. diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c index af0ed27b18f..031a0af96db 100644 --- a/gcc/haifa-sched.c +++ b/gcc/haifa-sched.c @@ -5707,7 +5707,8 @@ autopref_rank_data (autopref_multipass_data_t data1, static int autopref_rank_for_schedule (const rtx_insn *insn1, const rtx_insn *insn2) { - for (int write = 0; write < 2; ++write) + int r = 0; + for (int write = 0; write < 2 && !r; ++write) { autopref_multipass_data_t data1 = &INSN_AUTOPREF_MULTIPASS_DATA (insn1)[write]; @@ -5716,21 +5717,14 @@ autopref_rank_for_schedule (const rtx_insn *insn1, const rtx_insn *insn2) if (data1->status == AUTOPREF_MULTIPASS_DATA_UNINITIALIZED) autopref_multipass_init (insn1, write); - if (data1->status == AUTOPREF_MULTIPASS_DATA_IRRELEVANT) - continue; if (data2->status == AUTOPREF_MULTIPASS_DATA_UNINITIALIZED) autopref_multipass_init (insn2, write); - if (data2->status == AUTOPREF_MULTIPASS_DATA_IRRELEVANT) - continue; - if (!rtx_equal_p (data1->base, data2->base)) - continue; - - return autopref_rank_data (data1, data2); + r = autopref_rank_data (data1, data2); } - return 0; + return r; } /* True if header of debug dump was printed. */