From patchwork Wed Aug 8 14:35:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10560073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A986E1057 for ; Wed, 8 Aug 2018 14:35:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98E0C284A3 for ; Wed, 8 Aug 2018 14:35:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CE4F2AE6E; Wed, 8 Aug 2018 14:35:38 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,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 425AA284A3 for ; Wed, 8 Aug 2018 14:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbeHHQze (ORCPT ); Wed, 8 Aug 2018 12:55:34 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:35606 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbeHHQzd (ORCPT ); Wed, 8 Aug 2018 12:55:33 -0400 Received: by mail-ed1-f66.google.com with SMTP id e6-v6so1385021edr.2 for ; Wed, 08 Aug 2018 07:35:36 -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=d1vhHPnbw2OiYlfoXBdWdbgIhjykFlVRdbd28D9JUAQ=; b=CbOuB3XMSMpoyZqDMSmhjBvDfijLC2lgMI4VQooNQ8iiJ1MBUIN4SM1vSpij7liqzm fFu+hVJ8cbZBIIqTTDMuFqAXP2hZACmGijOKXucYBzXl4cf91UVfLoWvFEFBi/lwgMcu JttMinvFmHJdrJ09tIqWTQDEqejVX3lwk+H7ehcChZ042w0MgH8IMTPNbOTURnq9RU+F kdHsd1qMBRiEtJPWGDi/9+LTlBrbTLNduoAj1INBqdjoZ7Ibv9ras4JSbJjfjhzzgiN4 Nr/smb8GPJprg7V44UVQYHW0v+1wgD+SsrdLAnC+G62v9awLHtA/yov1xpTdRKU0smbn f2BA== 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=d1vhHPnbw2OiYlfoXBdWdbgIhjykFlVRdbd28D9JUAQ=; b=q1NYY0hPyuIabomG4nqhqxun+EUr2XYzBghqF6RxxxHVByaFNJqQ9W2QC1998UVri0 ebBU/T8rdSfKI6tVZji55OnvaxtO91HSOo/VEOlmnKjuKcB9zgZGhAYU6+6p9zu7Z5Dw hqd/5VzxVxtuzrGQdocy6I27fCdPT/Rmmnt8+c/ykfOhhDUF03RTyrDdPhYPt0CJFvmi +pxV9kvdji9ZaK4FmyDnwQV1J20BR1xII+S7/7EKmaozpB/lmSHM5iTeSRXAwCoqaDgH teYY4n2v48sI+VW1ID9Stvws5hprF8vEO4fC/gXSG08Kj3yclYX0s8oAyR/2FgeUGNjm p3Eg== X-Gm-Message-State: AOUpUlEBvF7RIyyhPshn1cAXwQeZeHlrNVtnhJaHg8ex2VYwRX27FfY+ +M4hcvfjMjGfwUJ/vv4Qra79UXmV X-Google-Smtp-Source: AA+uWPwqA2FOMPdqCGeNDaaJxcPQK37hxaNred+BnouC2vVAfz5yrztbZiojx0uDvNeEEHQR1R9X7A== X-Received: by 2002:aa7:d1cb:: with SMTP id g11-v6mr3514061edp.163.1533738936004; Wed, 08 Aug 2018 07:35:36 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4190:df00:d40b:3370:36b2:17ad]) by smtp.gmail.com with ESMTPSA id m20-v6sm1835326eds.5.2018.08.08.07.35.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 07:35:35 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/9] simplify ((A & M) | B ) & M' even when (M & M') != 0 Date: Wed, 8 Aug 2018 16:35:22 +0200 Message-Id: <20180808143528.82880-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180808143528.82880-1-luc.vanoostenryck@gmail.com> References: <20180808143528.82880-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, in simplify_and_or_mask(), the simplification is only done when (M & M') == 0. However it can be simplified anytime when (M & M') != M, resulting in a smaller mask. Allow the mask simplification when (M & M') != M. --- simplify.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/simplify.c b/simplify.c index 6b813d4f9..6a68ee5b4 100644 --- a/simplify.c +++ b/simplify.c @@ -833,9 +833,12 @@ static int simplify_and_or_mask(struct instruction *insn, pseudo_t and, pseudo_t return 0; omask = def->src2->value; nmask = omask & mask; + if (nmask == omask) + return 0; if (nmask == 0) return replace_pseudo(insn, &insn->src1, other); - return 0; + def->src2 = value_pseudo(nmask); + return REPEAT_CSE; } static int simplify_constant_mask(struct instruction *insn, unsigned long long mask) @@ -854,7 +857,6 @@ static int simplify_constant_mask(struct instruction *insn, unsigned long long m case OP_OR: // Let's handle ((A & M') | B ) & M // or (B | (A & M')) & M - // when M' & M == 0 src1 = def->src1; src2 = def->src2; if (def_opcode(src1) == OP_AND)