From patchwork Sun Nov 5 07:54:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 10042019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB79660247 for ; Sun, 5 Nov 2017 07:54:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4C5E29251 for ; Sun, 5 Nov 2017 07:54:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6D0829484; Sun, 5 Nov 2017 07:54:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37AFC29251 for ; Sun, 5 Nov 2017 07:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751136AbdKEHyw (ORCPT ); Sun, 5 Nov 2017 02:54:52 -0500 Received: from mail-yw0-f196.google.com ([209.85.161.196]:54007 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbdKEHyv (ORCPT ); Sun, 5 Nov 2017 02:54:51 -0500 Received: by mail-yw0-f196.google.com with SMTP id q126so5564754ywq.10 for ; Sun, 05 Nov 2017 00:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=t7XUQl2L12DDHQLtrCNHkpG3mvAdd0VP4nle5TDMIEY=; b=fqMa/ZKew4FaLnFvTcJeF35J1adulGGg1mK5Od6ZSe/auKJe2iSMAmjO1eUPI6ws9C WlN8e/LRfW3oseCLsbQ4uGjBEtscOve9Ejf+aISKCkDYNmqKzocL88VDy+LAS9DCI90g 0Av7EXjoBX3ZnglhqI89ipUWgOpFIXe/RXM3J8Z0DQ3d3/YClzibj/XKMINvxfnzhk5n x9vIuqkgHtN5muDdyv751gr/9qGZ5eDJm461foJUWzptoKwZIjDFCyTmdJhcq0riyfy4 zYctHFkrCOsGzukBuIx/3SNLIT6NoEwWBMzFQszCNzmNujxb8tMk6ox02A2ZT2IYuKI9 F3fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=t7XUQl2L12DDHQLtrCNHkpG3mvAdd0VP4nle5TDMIEY=; b=KQ2Bp+MienLdwzH6viLuLsn+Ov7OGK35zicGP71IV+USrQVjLxMAuydFD2OHIIHZ6g O/2uQFbkHiAPo8Qxw/OcnB8jVLKeD+1gmedCfeKar1FKWqOqCgW8IBMsFZ2Cno9gOBjl J5Jdtp7Onbmr2+yYKrT79F7tiZvYwfN7IzxW5Bx82FR28hZKpf5F7AkoMRh9BzJCc0SR rnvhVdeMLFcIAZJ8ugjTSCJv+dbcUwEpgy4vaFoTa1GZb9rNLy9LpsFHdQ0TqMYuFJxg /ZprQxwdevvxADPOVM+Cdqux+UrmU+uftZmMfRRyRHsEEMwKua5Sbz3clQaCNZw1z7Oi 2WQQ== X-Gm-Message-State: AMCzsaWfzvLdmCI/jhkN6qfKk/1AQznTGeogVmirInd61YbZ/j7LnTLe nXKOnlH8KUXNQ8DKw5we58JwXBgR+m+IGV7psuIg X-Google-Smtp-Source: ABhQp+TqxP3O33CgBIYqe5VfaatuRcS5UdviqZdc4bpSWlA2g1E/FUgAAYetCWQRazQugVrArCamQMlMraFtBmWmX0A= X-Received: by 10.129.72.18 with SMTP id v18mr7860613ywa.340.1509868490283; Sun, 05 Nov 2017 00:54:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.103.133 with HTTP; Sun, 5 Nov 2017 00:54:49 -0700 (PDT) From: Christopher Li Date: Sun, 5 Nov 2017 02:54:49 -0500 X-Google-Sender-Auth: mV_Wx6mKolZ3kYcdfdDazM9poQs Message-ID: Subject: [PATCH] Simplify expr->flags assignement To: Linux-Sparse , Luc Van Oostenryck , Nicolai Stange Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some back ground of this patch. After the I merge the constant expression series. I have setup my build machine to run some repeated stress test again each of the commit change. Each change has run 5 times and there is beak time between each stress run to allow the machine cool down. I am looking for the change that cause the biggest jump in the commit series. So that brings me to a patch in the series introduce the flags. I make some simplification on it. That is this patch. For the record, Here is the timing run back then with and without this patch, each has 5 run. It is hard to tell, but it seems the stress test can confirm the patch make a tiny little bit of difference. Big deal. :-) It has been a while, I might just sending it out before I forget about it. Chris $ stress.py exp 0 1 # cpus 24 exp~0 dc9902c Simplify expr->flags assignement real 1m18.737s user 20m54.255s sys 7m37.059s real 1m18.886s user 20m55.832s sys 7m35.513s real 1m18.900s user 20m56.276s sys 7m35.648s real 1m18.759s user 20m53.276s sys 7m37.484s real 1m18.829s user 20m55.247s sys 7m36.025s exp~1 17c0bae constexpr: flag __builtin_bswap() as constexpr real 1m18.959s user 20m55.826s sys 7m37.334s real 1m18.909s user 20m57.096s sys 7m36.704s real 1m18.906s user 20m57.002s sys 7m36.329s real 1m18.789s user 20m56.551s sys 7m36.875s real 1m18.964s user 20m56.409s sys 7m37.103s The same patch can be fetch on: https://git.kernel.org/pub/scm/devel/sparse/chrisl/sparse.git/log/?h=simplify-context-expr From 6d83f6ecb4e33b981ad6ec302be50d679ec2c3e9 Mon Sep 17 00:00:00 2001 From: Christopher Li Date: Thu, 24 Aug 2017 01:24:52 -0400 \ --- evaluate.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) @@ -920,8 +920,8 @@ static struct symbol *evaluate_binop(struct expression *expr) /* number op number */ if (lclass & rclass & TYPE_NUM) { - expr->flags = expr->left->flags & expr->right->flags; - expr->flags &= ~CEF_CONST_MASK; + expr->flags = expr->left->flags & expr->right->flags + & ~CEF_CONST_MASK; if ((lclass | rclass) & TYPE_FLOAT) { switch (op) { @@ -1036,7 +1036,7 @@ static struct symbol *evaluate_compare(struct expression *expr) if (is_safe_type(left->ctype) || is_safe_type(right->ctype)) - expr->flags = left->flags & right->flags & ~CEF_CONST_MASK & ~CEF_ADDR; + expr->flags = left->flags & right->flags & ~(CEF_CONST_MASK | CEF_ADDR); /* number on number */ if (lclass & rclass & TYPE_NUM) { @@ -1914,12 +1914,11 @@ static struct symbol *evaluate_preop(struct expression *expr) return evaluate_postop(expr); case '!': - expr->flags = expr->unop->flags & ~CEF_CONST_MASK; /* * A logical negation never yields an address constant * [6.6(9)]. */ - expr->flags &= ~CEF_ADDR; + expr->flags = expr->unop->flags & ~(CEF_CONST_MASK | CEF_ADDR); if (is_safe_type(ctype)) warning(expr->pos, "testing a 'safe expression'"); diff --git a/evaluate.c b/evaluate.c index b96696d3..9715b71d 100644 --- a/evaluate.c +++ b/evaluate.c @@ -906,8 +906,8 @@ static struct symbol *evaluate_logical(struct expression *expr) /* the result is int [6.5.13(3), 6.5.14(3)] */ expr->ctype = &int_ctype; - expr->flags = expr->left->flags & expr->right->flags; - expr->flags &= ~(CEF_CONST_MASK | CEF_ADDR); + expr->flags = expr->left->flags & expr->right->flags + & ~(CEF_CONST_MASK | CEF_ADDR); return &int_ctype; }