From patchwork Thu Nov 17 14:35:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9435161 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 0AE1460469 for ; Thu, 17 Nov 2016 18:46:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F17E5294A9 for ; Thu, 17 Nov 2016 18:46:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3DC929697; Thu, 17 Nov 2016 18:46:47 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 83BF7294A9 for ; Thu, 17 Nov 2016 18:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754584AbcKQSqr (ORCPT ); Thu, 17 Nov 2016 13:46:47 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35309 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752673AbcKQSqq (ORCPT ); Thu, 17 Nov 2016 13:46:46 -0500 Received: by mail-wm0-f67.google.com with SMTP id a20so24000826wme.2 for ; Thu, 17 Nov 2016 10:46:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dIYK1zHJDNZl3w+Pw3ip/650BLRiME2RiWHNjkPvglE=; b=HKNwj2l5dtyuaD/icqCzf4u2Y3gFSMvBleduArpRAuo3lWkBzCSb0b3Xio125qo3cU UaJnaSKP/WZMdUahu3nz5r78oIDDCLVo/sc2h1zPXDI4YMXZFa1Euuln4IgtpTGifAX4 cV0p554TwDrbmwGs/+bBnm4q1KIJ2zQajy5MgX2eKD6W0RJy3ZJ2gY9AA4BUuacfBFCC jgMc3SN6TH3cCRNXuR4XS8COdo9049khcrSQS5lvblF4bji3a9UVBjj/5Tbu1W+0rCQs AQQsmLfrASBWs6NCmj+35QVBK4yT/AbzYr0dEcstWXzh+UjTrSuF2NctBnlzGxhYJBsf y0rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dIYK1zHJDNZl3w+Pw3ip/650BLRiME2RiWHNjkPvglE=; b=fZD9ydU7eIBEDL62xlsRHv4IyO+pSKIfIHjVOspKXJnAm2dOqZoySQpcdcKcvS/b7K hBGMtfzbw3ChPAiuTAwBqfbHQG5MfnCANkKpDRx5D6Six0zCssOBIG9vXeq+plogS+W2 mVbAAG638x7OtLW1nfzT8Ce6m1hAiMDqnFe3LAbgcBw9+zJfSvHqjofervtY6TBKT3KX HIlzGeg10XZYILm7iAkIHm9KHYe274o9TZ251uw6S8tgwtC6oq9BgWlhNCFtLVLNbyNA +YgdmkRHKhYqIxdkmAGGzIdpGqb0RhwwLyHerEVi3vwLmiDzmXb5wReYosiyyyLtMNfa 3ffA== X-Gm-Message-State: ABUngveL60bQTwxxupQJpeB/tasRXmFMVMsF934Ru4kIQ0j+8CmlFbeW89WXCqJVnLqRlg== X-Received: by 10.28.127.14 with SMTP id a14mr4359735wmd.80.1479393321930; Thu, 17 Nov 2016 06:35:21 -0800 (PST) Received: from localhost.localdomain (80.225-245-81.adsl-dyn.isp.belgacom.be. [81.245.225.80]) by smtp.gmail.com with ESMTPSA id 138sm4069814wms.20.2016.11.17.06.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2016 06:35:21 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 2/8] fix killing OP_SETVAL instructions Date: Thu, 17 Nov 2016 15:35:01 +0100 Message-Id: <20161117143507.3598-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161117143507.3598-1-luc.vanoostenryck@gmail.com> References: <20161117143507.3598-1-luc.vanoostenryck@gmail.com> 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 Currently, kill_instruction() ignore OP_SETVAL instructions with the result that some instructions are not optimized away as expected. For example, when looking at the output of test-linearize, the following function: static int kill_setval(void) { l: return &&l && 0; } gives the following output: kill_setval: set.64 %r6 <- .L1 ret.32 $0 The 'set' instruction is obviously unneeded but nevertheless present. With the patch, the output is the expected: kill_set: ret.32 $0 Signed-off-by: Luc Van Oostenryck --- simplify.c | 1 + validation/kill-replaced-insn.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/simplify.c b/simplify.c index 85da5bec..d07ca1b1 100644 --- a/simplify.c +++ b/simplify.c @@ -195,6 +195,7 @@ void kill_instruction(struct instruction *insn) repeat_phase |= REPEAT_CSE; return; + case OP_SETVAL: case OP_NOT: case OP_NEG: insn->bb = NULL; kill_use(&insn->src1); diff --git a/validation/kill-replaced-insn.c b/validation/kill-replaced-insn.c index be031b6c..92021877 100644 --- a/validation/kill-replaced-insn.c +++ b/validation/kill-replaced-insn.c @@ -30,6 +30,12 @@ static int kill_select(int a) return (a ? 1 : 0) && 0; } +static int kill_setval(int a) +{ +l: + return &&l && 0; +} + static int kill_load(int *a) { return *a && 0; @@ -51,4 +57,5 @@ static int kill_store(int *a) * check-output-excludes: ptrcast\\. * check-output-excludes: fpcast\\. * check-output-excludes: sel\\. + * check-output-excludes: set\\. */