From patchwork Fri Jun 22 09:11:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 139589 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp633392lji; Fri, 22 Jun 2018 02:12:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXXJWN3zlfZ8cREmDlUimhJgLaKlXALvwiF3eLMENTadPcVijbJUPuqa+n9RLELKMVdfaV X-Received: by 2002:a65:6619:: with SMTP id w25-v6mr661796pgv.195.1529658747159; Fri, 22 Jun 2018 02:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529658747; cv=none; d=google.com; s=arc-20160816; b=YJT6k+rPvZmLAJEp5/ZUbFsw5x5RfedQr7vJDQ7qOI2DYlKNQpIVMDE2+9hXz5GpbO vFi5bVxiCZMeDozc0nd1Xi6huna/kn7kk5mGdfCvb1RZYbZr7si+AK85KTxUVm7Hf/t1 +L0fyRcL1gBylPxe7UcabIwees+qANoI2Oirn3hGItsLQTuCGVsyPILVGW1PeVrYtZt6 kus1Vt+C6qn9t220451xA5tOSGceIOv8B93y2dst4dWGX3PtEBccG/sLkuPkTTjDmWpU gTXK9DY2rhC/dndiGoe58mLnRPc07AsbyRuG/3RfgZROCowlIBOrR3QYucQk7M3wU/jy w4iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=8px6x1IbQKHxljTXakBdR4jM5sCcDfcu1UcMOviYsj4=; b=z5J/Ba54ex8RHxuau+jpIvW7x+qTUxkxmCUvb2mgoMhaJwxb4oo8wJlhHBNzXvOL9b 0f4cL+tqODZj1rHOiqnqpKuDn1XgzLW2a4VXd+7Lo0LJig5FSRtkHsAp5HSde491mY+R Bc1rjpWxX+02l8fL9f+Zmh7IyARF1zZe+reWThN36mLE6lLkmdhCx31aSxhUiwlIcW90 TkPGOGSRQl0+C0XruY55aDnQIEmCBv+ixYi7qNCJi1I916q/5JW/LAGI+NnXwOnTDf0l VzgqukI20suGwHvNoHuTT3Xj85V8QeDhc06DSL6IQcdPC3x2ycoUVVYEYcHs5O3dFst3 O50A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eQj46gXQ; spf=pass (google.com: domain of gcc-patches-return-480260-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-480260-patch=linaro.org@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id a73-v6si7300414pfl.349.2018.06.22.02.12.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jun 2018 02:12:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-480260-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 header.s=default header.b=eQj46gXQ; spf=pass (google.com: domain of gcc-patches-return-480260-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-480260-patch=linaro.org@gcc.gnu.org"; dmarc=fail (p=NONE sp=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=nG1q44xlC7A6IXcfR7IHPAjyr+LK2/mipR41LMMtS/JPWa dL1RHbf8P/07s6cu5W5p2CIKyhK7kTKmM5CF5MRG0tFGuFhPmAQ6XvLlXCmB9FuS vM/6d/rOj2D+FFEusKBjCwTlwh+Qg0gn1PxUnKxqXu3J7NWTysuVvJN/nlQwg= 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=QL/SQYw5AdsR1cbQPN4DkQuAOOc=; b=eQj46gXQ6r4ph0vhykPo DhD7+0VVrDPNA7gtndFXcrP7QTw6CbT/2YBDF2cnGQtgaa6ePjbzF+Qg6DF2O0m5 yal9V5uhi8Q0jCW8ZrSDQqwwYTAZu3EYD94B343EAq/YuTSauXKa04Vyi/CuLxLh UgqCDYQkWohMLMqPujxQB9o= Received: (qmail 32928 invoked by alias); 22 Jun 2018 09:12:16 -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 32917 invoked by uid 89); 22 Jun 2018 09:12:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, SUBJ_ALL_CAPS autolearn=no version=3.3.2 spammy=advised X-HELO: mail-lf0-f51.google.com Received: from mail-lf0-f51.google.com (HELO mail-lf0-f51.google.com) (209.85.215.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Jun 2018 09:12:13 +0000 Received: by mail-lf0-f51.google.com with SMTP id e13-v6so8099096lfc.1 for ; Fri, 22 Jun 2018 02:12:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8px6x1IbQKHxljTXakBdR4jM5sCcDfcu1UcMOviYsj4=; b=B7kno64eDAiq1OIGF5u5yvAPFiIYALKnYuCWYww9pVWRNXbqQ6N0GCf8sB/Kvkj50O PiWho2bkZhmcx8sQyuTbYOHCE8pdtJXuj1zoNh46VOpYF/eL6J7rLQWvii9dReRR2qgT N1tpWZuoIeNPsnwNhRfyeIPk2DWPpC+xGAkcJ5NTDvn+HLQNVY5re0prFvlvgp0fAsH6 8Lu55Zpxvlic3fex112/dKkGL5trKBmp65ExIUEUidolh+u8x3BQIkitlsXqOBIYUXUH DABoZc8Jq5FWjHgudCwMLAWtLA9wc8a1QXN7OyxpXEFqojkZR2cjL0sQB7YbgLO78Q98 YODw== X-Gm-Message-State: APt69E14Nm/hNyS5p9rXzaRqsYF0fdcfQexLGtbMQoZv/OZXMpD9r8ck 7zRPm1lKDsAsAz8egrh2XSlvbwm33KbFCMM60IkBhrirDXs= X-Received: by 2002:a19:921a:: with SMTP id u26-v6mr632647lfd.89.1529658731060; Fri, 22 Jun 2018 02:12:11 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:1302:0:0:0:0:0 with HTTP; Fri, 22 Jun 2018 02:11:30 -0700 (PDT) From: Kugan Vivekanandarajah Date: Fri, 22 Jun 2018 19:11:30 +1000 Message-ID: Subject: [PATCH 0/3][POPCOUNT] To: GCC Patches X-IsSubscribed: yes When we set niter with maybe_zero, currently final_value_relacement will not happen due to expression_expensive_p not handling. Patch 1 adds this. With that we have the following optimized gimple. [local count: 118111601]: if (b_4(D) != 0) goto ; [89.00%] else goto ; [11.00%] [local count: 105119324]: _2 = (unsigned long) b_4(D); _9 = __builtin_popcountl (_2); c_3 = b_4(D) != 0 ? _9 : 1; [local count: 118111601]: # c_12 = PHI I assume that 1 in b_4(D) != 0 ? _9 : 1; is OK (?) because when the latch execute zero times for b_4 == 0 means that the body will execute ones. The issue here is, since we are checking if (b_4(D) != 0) before entering the loop means we don't need to set maybe_zero. Patch 2 handles this. With that we have [local count: 118111601]: if (b_4(D) != 0) goto ; [89.00%] else goto ; [11.00%] [local count: 105119324]: _2 = (unsigned long) b_4(D); _9 = __builtin_popcountl (_2); [local count: 118111601]: # c_12 = PHI <0(2), _9(3)> As advised earlier, patch 3 adds phiopt support to remove this. Bootstrap and regression testing are ongoing. Is this OK for trunk. Thanks, Kugan