From patchwork Tue Aug 8 23:06:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9889245 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 49E82603F2 for ; Tue, 8 Aug 2017 23:07:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D26C2891C for ; Tue, 8 Aug 2017 23:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 319C828A22; Tue, 8 Aug 2017 23:07:06 +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 E287F28951 for ; Tue, 8 Aug 2017 23:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752324AbdHHXHD (ORCPT ); Tue, 8 Aug 2017 19:07:03 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36349 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752523AbdHHXHB (ORCPT ); Tue, 8 Aug 2017 19:07:01 -0400 Received: by mail-wm0-f66.google.com with SMTP id d40so4904237wma.3 for ; Tue, 08 Aug 2017 16:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cVWpQzfIsy3koKGEVGEIKxUeOJ3FLF4zA+M0687Z8qc=; b=j5hqKEencj2tlyqozsgAtOfCYl+iKF8nFm2LMGOo75MiGi7WWnAbeB61KOVPofi90N /cGPG/4WjHmXouLPUtHGy+/XWvzgiOcgIes5P1BMLtV0FOIJrJz5vosJgGSI9hB/M8sT DML28ZZ6LA+SyMes3J0dbRr1+nKlP7JdgGw6CQdLeuMHTaZIInxwcr9Q1uPRaBRAtkee D2Fa/yvrJoyC/igntgnVkZ8FJSbj2Mxh3pbsk09445s+kH/K++bhzH/bdu78LaHD+djA 42bldexDkLuOw3qXWUjh32/0Ipv69eKKdX1BsWA5qwNYiC2sNkinG69+mtXcvbkaCSt0 8jkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cVWpQzfIsy3koKGEVGEIKxUeOJ3FLF4zA+M0687Z8qc=; b=sdfDtk4am3N/6CVAYQpFOvjH2216bzp/7WGAXGFr/xiIXQREF/l2ozmA71NkiVX9kF nVLFTWHVZmke1+yeSQlssTkpplMIwYOi88jdt2+3M1TzIf/Ey7pVUl6CDy50LSl7d7f7 GTnsQLxWJV2FLlOMnQ6Kq0CbKwL7RLfEHImCMtFkgN7Eq0vieHCMzgxWEeZeslyB78tq PAIvkZ5ypmOS2a7bsXyV1aDTYjyIaCX+iXf1OIyzeEhLlLSW/IuqCIVW0WmeNLlJ96Rc Qk50Jt0WpLEzsoQbgcJeX8HDDxZF9jIyZqggzbLt37AQ1x1N/nQAhLnzx17ZGR6cCvZ1 vPyw== X-Gm-Message-State: AHYfb5gY1Wbx4QDwonHBEYnKQESR5+MJyAgPUcEwOfywCIeldDscuBGM y2xSZXGGcd7AKooUavA= X-Received: by 10.80.181.111 with SMTP id z44mr5854759edd.74.1502233620494; Tue, 08 Aug 2017 16:07:00 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4076:600:6494:649b:1a34:f1b]) by smtp.gmail.com with ESMTPSA id n15sm1133490edb.87.2017.08.08.16.06.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Aug 2017 16:06:59 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Linus Torvalds , Dibyendu Majumdar , Luc Van Oostenryck Subject: [PATCH v3 8/8] fix: cast of OP_AND only valid if it's an OP_CAST Date: Wed, 9 Aug 2017 01:06:34 +0200 Message-Id: <20170808230634.16227-9-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170808230634.16227-1-luc.vanoostenryck@gmail.com> References: <20170808230634.16227-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 A cast of an OP_AND can be simplified away if the mask already 'cover' the value. However this cannot be done if the cast is in fact a sign-extension. Fix this by adding the appropriate check of OP_CAST vs. OP_SCAST Fixes: caeaf72d34d1e91aaea7340241232d1d877907b7 Signed-off-by: Luc Van Oostenryck --- simplify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 23cdd19ae..daf91d82b 100644 --- a/simplify.c +++ b/simplify.c @@ -1046,7 +1046,7 @@ static int simplify_cast(struct instruction *insn) } /* A cast of a "and" might be a no-op.. */ - if (def_opcode(src) == OP_AND) { + if (insn->opcode == OP_CAST && def_opcode(src) == OP_AND) { struct instruction *def = src->def; if (def->size >= size) { pseudo_t val = def->src2;