From patchwork Tue Apr 10 10:40:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 896572 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-476118-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (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="COliOoQz"; 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 40L3cf3DS8z9s2S for ; Tue, 10 Apr 2018 20:41:22 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=KVIj8AD/Zs+5VSCB4omSHWSMdmB3F9EpH/EjZT8baDi1/jrISckM7 cRxo26Q18ZZrwA0pbq/XscVYjqyywh/bGj5uCAqWSZZRxZd4Z85iFmcOIMX/gzGT bY8jPTx+n/PU6ojN8U3ieLHR0MqeYOqEUrvGN9ZH/3pGMbIbLoLYM0= 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:subject:message-id:mime-version:content-type; s= default; bh=vmhR5Et/6aGRyTE6KaJAllw1PLg=; b=COliOoQz7iALQaU4bAJS ygIv2CjDn78U9Q0CebS1SPPD5U8Ob+jpkZGWOc57Mt1oO4p7LVAfWqV/mOFBWmNm J3n1KJDloi8n5hBOS6sRfUvKwOCOQDfAkOI4NnW0gtaUTuFEGhkF2d4b+ZFNpeym ZXH1RLN/xsZsakW6AQPhQes= Received: (qmail 32514 invoked by alias); 10 Apr 2018 10:41:13 -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 32383 invoked by uid 89); 10 Apr 2018 10:41:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=umbrella, withcpu, with-cpu 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, 10 Apr 2018 10:41:10 +0000 Received: from monopod.intra.ispras.ru (monopod.intra.ispras.ru [10.10.3.121]) by smtp.ispras.ru (Postfix) with ESMTP id 6A262203B2 for ; Tue, 10 Apr 2018 13:41:08 +0300 (MSK) Date: Tue, 10 Apr 2018 13:40:45 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org Subject: [PATCH] sched-deps: respect deps->readonly in macro-fusion (PR 84566) Message-ID: User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) MIME-Version: 1.0 Hi, this fixes a simple "regression" under the qsort_chk umbrella: sched-deps analysis has deps->readonly flag, but macro-fusion code does not respect it and mutates instructions. This breaks an assumption in sel_rank_for_schedule and manifests as qsort checking error. Since sched_macro_fuse_insns is only called to set SCHED_GROUP_P on suitable insns, guard the call with !deps->readonly. Bootstrapped/regtested on x86_64 with sel-sched active and --with-cpu=sandybridge to exercise macro-fusion code and verified on aarch64 cross-compiler that the failing testcase given in the PR is fixed. OK to apply? Thanks. Alexander PR rtl-optimization/84566 * sched-deps.c (sched_analyze_insn): Check deps->readonly when invoking sched_macro_fuse_insns. diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c index 9a5cbebea40..120b5f0ddc1 100644 --- a/gcc/sched-deps.c +++ b/gcc/sched-deps.c @@ -2897,7 +2897,8 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn) && code == SET); /* Group compare and branch insns for macro-fusion. */ - if (targetm.sched.macro_fusion_p + if (!deps->readonly + && targetm.sched.macro_fusion_p && targetm.sched.macro_fusion_p ()) sched_macro_fuse_insns (insn);