From patchwork Thu Nov 10 05:25:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 81600 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp556489qge; Wed, 9 Nov 2016 21:26:25 -0800 (PST) X-Received: by 10.99.56.82 with SMTP id h18mr32241450pgn.55.1478755585501; Wed, 09 Nov 2016 21:26:25 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d26si2997737pge.35.2016.11.09.21.26.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Nov 2016 21:26:25 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-440917-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-440917-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-440917-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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:from:date:message-id:subject:to:content-type; q= dns; s=default; b=gazZ+0XW3Ye77hum0H0sCtcbFpW2k7j42nzmXNJ/sSf9hh Q1p1orpD2sEmuFpLDwReqbzj8kr/zSzfIcimBHcnGu2lGjyIBoEDfEbaPkPzH+KB qUcpi519hzQX3/toN/H3fMlAl5bCTHj8WVUdyudan9YovLO3uw4PCWpUK+x0M= 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:from:date:message-id:subject:to:content-type; s= default; bh=1ipYh/Ye33wDaARNrGpZyf0v4Uo=; b=xSvvIehPlsE+Z5PH8Boi 4BFtjiYjdVpC4xNrvhVOTLsUT/ScpV45Ehgi0k0VWC6p5xSVoHTp4B2Ya4PgYWeY DKaEVeqPPsN5jnUf1o8XLmwjzYJPJGD3W68fFGmVxCKbJLvV5FEhauIVhybxK2ie gAIG9SV3jWoc1ec63AfrRoY= Received: (qmail 29517 invoked by alias); 10 Nov 2016 05:26:11 -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 29501 invoked by uid 89); 10 Nov 2016 05:26:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=wilson, Wilson, Hx-languages-length:2464, sk:treelo X-HELO: mail-yw0-f177.google.com Received: from mail-yw0-f177.google.com (HELO mail-yw0-f177.google.com) (209.85.161.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Nov 2016 05:25:56 +0000 Received: by mail-yw0-f177.google.com with SMTP id a10so1060402ywa.3 for ; Wed, 09 Nov 2016 21:25:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YQOHmb8rJ69m6y3/26fWubGlE+sAgARrojzxWKej71g=; b=kCmDFTTYjnqqWx3O7/cDQClEGNi3A5uCGP9PN0hzu/wJyDXEp5pQm9Gp6dUpbWGPfS S38i6iNDCDKZXQxBN3qgGJvWUrUpu8pap363Xtd3MRUwBh4f8Wp28NW6d3iic4gUSg78 BPgBN8ZJuvHw//3x781qs24PoFJlAblMgd9PIgdw0AK6Kn/5jNVnpY/vi+wPuRAMhM2R yzQOTXKiEBnPryfUpceXqEH1euyc/xo1sCuY4wnox9lK21okcQfT5nSBwkvh5JmG1S4V 7XJb76eIqoddEwavdJzhHE4ao8uioEaZ3ZJ/DPXnRJbWhlvwwT1K7pNWDwGcagYtIiy3 mn4Q== X-Gm-Message-State: ABUngvcSosDPjIlONjk3alNsQ3X8P31+XTz3bmvBm2W/lXF7SoCGpvuyPBhxH3R+EDx3A+VWdrFdAMy0b3H6GEwj X-Received: by 10.129.163.69 with SMTP id a66mr3693411ywh.175.1478755554717; Wed, 09 Nov 2016 21:25:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.108.211 with HTTP; Wed, 9 Nov 2016 21:25:54 -0800 (PST) From: Jim Wilson Date: Wed, 9 Nov 2016 21:25:54 -0800 Message-ID: Subject: [PATCH] loop distribution bug fix To: "gcc-patches@gcc.gnu.org" This fixes a bug in code adding edges to the dependence graph. Values for this_dir can be -1 (backward edge), 0 (no edge), 1 (forward edge), and 2 (both backward and forward edges). There can be multiple dependencies checked, creating multiple edges that have to be merged together. this_dir contains the current edge. dir contains the previous edges. The code fails to handle the case where this_dir is 2, in which case we can return immediately. This is a minor optimization to improve compile time. The code handles the case where dir is non-zero and this_dir is zero by returning 2, which is incorrect. dir should be unmodified in this case. We can return 2 only if both dir and this_dir are non-zero and unequal, i.e. one is -1 and the other is 1. This problem creates extra unnecessary edges, which can prevent loops from being distributed. The patch fixes both problems. This passed an x86_64 gcc bootstrap with -ftree-loop-distribution added to BOOT_CFLAGS and a testsuite regression check. Curiously, I see that I get different results for the C/C++ ubsan tests every time I run them, but this has nothing to do with my patch, as it happens with or without my patch. I haven't tried debugging this yet. Might be related to my recent upgrade to Ubuntu 16.04 LTS. Otherwise, there are no regressions. On SPEC CPU2006, on aarch64, I see 5879 loops distributed without the patch, and 5906 loops distributed with the patch. So 27 extra loops are distributed which is about 0.5% more loop distributions. There is no measurable performance gain from the bug fix on the CPU2006 run time though I plan to spend some more time looking at this code to see if I can find other improvements. OK? Jim 2016-11-09 Jim Wilson * tree-loop-distribution.c (pg_add_dependence_edges): Return 2 if this_dir is 2. Check for this_dir non-zero before dir != this_dir check. Index: gcc/tree-loop-distribution.c =================================================================== --- gcc/tree-loop-distribution.c (revision 242025) +++ gcc/tree-loop-distribution.c (working copy) @@ -1408,9 +1408,11 @@ pg_add_dependence_edges (struct graph *rdg, vec