From patchwork Tue Apr 16 11:59:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Zhuykov X-Patchwork-Id: 1086261 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-499306-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ispras.ru Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Cvtc/Xit"; 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 44k3p8353Xz9s4V for ; Tue, 16 Apr 2019 21:59:58 +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 :mime-version:content-type:content-transfer-encoding:date:from :to:subject:in-reply-to:references:message-id; q=dns; s=default; b= S3TU9xpFSSB7NrMCe89F+D/AmITwW1AIj/C+x/yd7LXyUdQ+dE5EhWhWRh8YQFJI LilVBsA0cljNfaLsDXQYHja58TuK0/bCY2pL8qhXneMQf5zauuRbekkLlYN3Fr+j mZcxzyCfaBjhHM/5WyTTyvHXO8EiLOdRDCYGph6VdL4= 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:content-type:content-transfer-encoding:date:from :to:subject:in-reply-to:references:message-id; s=default; bh=Iop L7Ax1ol1+DHipxOJbJX2YrHE=; b=Cvtc/XitR/GAN0MDJsaCARg30Wm6VX95Sl/ McV7Zy3Ez4nDi3/b8GTF/2eDVIzBdeDYciCIB1yFiWik/QFTo7YXAin/eqIzWrM1 66VYrkbgYDWUPGAwGVQVRVk85GzVN+I1Up1wavXa+DKxKqFabMag/J9MShj6+mTo YbG5PlUc= Received: (qmail 73301 invoked by alias); 16 Apr 2019 11:59:51 -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 73290 invoked by uid 89); 16 Apr 2019 11:59:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:fc9f9b2, H*f:sk:fc9f9b2, letter, H*F:D*ru X-HELO: mail.ispras.ru Received: from mail.ispras.ru (HELO mail.ispras.ru) (83.149.199.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Apr 2019 11:59:50 +0000 Received: from mail.ispras.ru (localhost [127.0.0.1]) by mail.ispras.ru (Postfix) with ESMTPSA id B8990540094 for ; Tue, 16 Apr 2019 14:59:47 +0300 (MSK) MIME-Version: 1.0 Date: Tue, 16 Apr 2019 14:59:47 +0300 From: Roman Zhuykov To: gcc-patches@gcc.gnu.org Subject: [1/4][PATCH] Fix PR84032 In-Reply-To: References: Message-ID: <5fc2854cd659a06162947de4a3aea660@ispras.ru> X-Sender: zhroma@ispras.ru User-Agent: Roundcube Webmail/1.1.2 There is the following mistake in logic behind the code. We want to schedule the branch instructions only as a last instruction in a row. But when branch was scheduled and we add other instructions into partial schedule, we sometimes allow them to be in same row after the branch. The issue happens later when we try to reschedule branch into another row, algorithm there works like this: (1) Remove branch from the row where it is (say, “previous row”) (2) Try insert into the needed row (3) If success – OK, continue scheduling other instructions (4) But when inserting (2) was not done – insert it back into “previous row” and this insertion must be certainly successful, which is checked by assertion. But when on step (1) branch in not last in a row there is no guarantee, that on step (4) we could insert it back, because there we will try only last-in-a-row position for it. This patch solves this totally preventing other instructions to be scheduled after branch in the same row. I’ve described patch testing in cover letter. Ok for trunk? gcc/ChangeLog: 2019-04-09 Roman Zhuykov PR rtl-optimization/84032 * modulo-sched.c (ps_insn_find_column): Change condition so that branch will always be the last insn in a row inside partial schedule. gcc/testsuite/ChangeLog: 2019-04-09 Roman Zhuykov PR rtl-optimization/84032 * gcc.dg/pr84032.c: New test. +} diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c --- a/gcc/modulo-sched.c +++ b/gcc/modulo-sched.c @@ -2996,9 +2996,7 @@ ps_insn_find_column (partial_schedule_ptr ps, ps_insn_ptr ps_i, last_must_precede = next_ps_i; } /* The closing branch must be the last in the row. */ - if (must_precede - && bitmap_bit_p (must_precede, next_ps_i->id) - && JUMP_P (ps_rtl_insn (ps, next_ps_i->id))) + if (JUMP_P (ps_rtl_insn (ps, next_ps_i->id))) return false; last_in_row = next_ps_i; diff --git a/gcc/testsuite/gcc.dg/pr84032.c b/gcc/testsuite/gcc.dg/pr84032.c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84032.c @@ -0,0 +1,23 @@ +/* PR rtl-optimization/84032 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fmodulo-sched" } */ +/* { dg-additional-options "-mcpu=power6" { target { powerpc-*-* } } } */ + +void +yr (int cm) +{ + int ka = cm; + + for (;;) + { + short int m0; + + for (m0 = 0; m0 < 6; ++m0) + { + ka &= 1; + cm *= 2; + } + + ka = (ka == 0) ? cm : 0; + }