From patchwork Wed Mar 10 21:49:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92732C433DB for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65FA364FAB for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232465AbhCJWLN (ORCPT ); Wed, 10 Mar 2021 17:11:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231935AbhCJWLC (ORCPT ); Wed, 10 Mar 2021 17:11:02 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA44C061574 for ; Wed, 10 Mar 2021 14:11:01 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id bm21so41924821ejb.4 for ; Wed, 10 Mar 2021 14:11:01 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=s5g21rtrUkKyIAe0NxocjKGj1w5N65WEaFKudZER4Bg=; b=f7kATUtNXP7XI8jdvYNvllNdodOSeKY6fhR7KUS40qLDVP31J8RZgy2njImdzLrlci I+yzA3TR8sBTa5hasrRcNkPYn+b/yI+F+luajm9B5ysud1jCATgwi5fCr/4fvb8JO9L1 h4elR5OYn27OJJOATWUhM97b6Sqif/0kKhxhudK1C/koCoSMLGXiQRt+sn9y7TTHe+0T TcrvvhjEHfeVkKrQk9IVbrYV1+Ykkuc2Tbb+1CLZjC9SryJYG7N7jbqPh7Pb/kEEPW3D jaXZiOcyT1s1rrSRBLu9mFx3FlAOaw+Wg4KitWES6tx1twVXLCYICo8s9KtNQt1mD5rB nbFQ== 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:mime-version:content-transfer-encoding; bh=s5g21rtrUkKyIAe0NxocjKGj1w5N65WEaFKudZER4Bg=; b=AAQHwQBcqnIgFL+QlbKMxL55Ni1UeE7CmXrlSstVZ5b6nPlQOAmRKYnuGNPINafcye GKHEjyklL38J0fpm6g5QgRlBlIa6NafLuDmvfQnGOIiP3BwxQ0R2dZtt4CKu0J/6tdL+ wVAowDNvwqhoD9pOJBpQitpXjfLAyXhPRGh7xN7d6irXDeuvUCDBTT/eTMs8EKQafNAr 53aGXC8XX15pX2TrMn+UkZELa7H+7KNMHMabvY/pf+UxSnYajJ+/A4FgPkM0Ro75HQvn w8+celEKYx+V2H0nW2Ghr0GYVJKDoOxP26tujBIYsnjVHZB2UwUzs0nlj05c8YF2doU3 jqvg== X-Gm-Message-State: AOAM533RctvL+I+bV0gNiix0lWch9M2rz1NcLXf3dCIcFIlEBU7H+Qc1 e5j5Su66oM31kGjX/RbqDVlDSDKC0pQ= X-Google-Smtp-Source: ABdhPJxB4xPiT7Vo3ckl6HVvX31H1P9GUcLxVtcYlQKXBgpShf0jH0twoc5H3ch2T+QPR2Y4SyRt1w== X-Received: by 2002:a17:906:1c41:: with SMTP id l1mr50574ejg.299.1615414260534; Wed, 10 Mar 2021 14:11:00 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:00 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/9] change testing of signed compares against SMIN or SMAX Date: Wed, 10 Mar 2021 22:49:42 +0100 Message-Id: <20210310214950.84192-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org These tests are written by testing if the comparisons are equal to their expected value: 0 or 1. So, a compare of a compare but such compares of compare have their own simplification which defeats what's tested here. So, rewrite the test to avoid such compares of compare. Signed-off-by: Luc Van Oostenryck --- validation/optim/cmps-minmax.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/validation/optim/cmps-minmax.c b/validation/optim/cmps-minmax.c index 5802cdbcafd1..0b1a0a099d7d 100644 --- a/validation/optim/cmps-minmax.c +++ b/validation/optim/cmps-minmax.c @@ -1,11 +1,11 @@ #define SMAX __INT_MAX__ #define SMIN (-__INT_MAX__-1) -int lt_smin(int a) { return (a < SMIN) == 0; } -int le_smax(int a) { return (a <= SMAX) == 1; } +int lt_smin(int a) { return (a < SMIN) + 1; } +int le_smax(int a) { return (a <= SMAX) + 0; } -int ge_smin(int a) { return (a >= SMIN) == 1; } -int gt_smax(int a) { return (a > SMAX) == 0; } +int ge_smin(int a) { return (a >= SMIN) + 0; } +int gt_smax(int a) { return (a > SMAX) + 1; } /* * check-name: cmps-minmax From patchwork Wed Mar 10 21:49:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7F0FC4332E for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC5F764FC3 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231935AbhCJWLO (ORCPT ); Wed, 10 Mar 2021 17:11:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233131AbhCJWLC (ORCPT ); Wed, 10 Mar 2021 17:11:02 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 929B3C061574 for ; Wed, 10 Mar 2021 14:11:02 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id ox4so26299816ejb.11 for ; Wed, 10 Mar 2021 14:11:02 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=ztCjPU6H5NUjyIzKarCMxklwx0LRyOBxLTvY6YHpE1c=; b=WGR4ZDS1z2rCDSn96/YTUn+Xbn1PD+GMWM7+K6NkjHV2382M501LTE8cf1JE0UhASg 4n72BcqP5OhfaChYMP3FGA3jv6Bvv7sQdLX9tq6c5ayQtPqY1I0YhXsZEwWafFAmU6VB VEnNtAwkKMeFb2eZAk40TsiKqL1CArEbYPIvlmiHqu7Ys6qdAg4lvK5wRsvEYxqm4Ph1 sc6TXKIaqUrQRkYf7p4aXL29Wa/ydIIpV26BIC7NWJHvtCkTQgxywU1Lap184iZbTAGR yMw7SlDjjqaXmXuRdoOGOSKcIkKZX+1S8Gj5PjhpQmGkh2Hc9KLDGfeNjwHTdfCfMOVH ji8g== 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:mime-version:content-transfer-encoding; bh=ztCjPU6H5NUjyIzKarCMxklwx0LRyOBxLTvY6YHpE1c=; b=sSMvapWKJ6IQu80SuwGuKgDpD5DGIg0xIpTXn+9jXlDALLHC+cZs2fTbpiVtLnDndo 6peZ0neQyrIlPaGB2Gm7ADyfiLVQpWoA7ivn3Eck2Fvkw9WZFHfmSOorRvfPeId/a1HE qcw+VGwU4GFMeoSbQqflMFf3st2+NIY/aNYdW5PhRLiV5iHceWmuAW/IarAEDKUjazeM yPLzF+srellwZnmqLQhvKtndylHJpDaxDh9btquWGTsSMQwNaLmlSdCxGzG4nkJ2iQE0 srNJ/TMuPW19xIxqnws73JLjPqcq4Y9KEVpaQ6OSJv8hd/HfRGb9p7+sDCz9xjY3Ewif WhiA== X-Gm-Message-State: AOAM530yyq9dmmYGvRFhsOT9y+Ey6dPHMYBwWcuzvu2ROnjNn0nVIgRa +kG7isCBQdz+do+SMuWkfaB/M4CKLrY= X-Google-Smtp-Source: ABdhPJyQXEv1hAPrNqId1eieZju1khNoW1SJOo1iLtSqxFMYt2qIk/xDo0dKsKE2mB7slQiRC7pxgw== X-Received: by 2002:a17:906:b4c:: with SMTP id v12mr77333ejg.330.1615414261319; Wed, 10 Mar 2021 14:11:01 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:00 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/9] add testcases for constant compares against AND/OR Date: Wed, 10 Mar 2021 22:49:43 +0100 Message-Id: <20210310214950.84192-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- validation/optim/cmpe-and0.c | 11 +++++++++++ validation/optim/cmpe-or0.c | 11 +++++++++++ validation/optim/cmps-and0.c | 22 ++++++++++++++++++++++ validation/optim/cmps-or0.c | 22 ++++++++++++++++++++++ validation/optim/cmps0-and0.c | 13 +++++++++++++ validation/optim/cmpu-and0.c | 18 ++++++++++++++++++ validation/optim/cmpu-or0.c | 19 +++++++++++++++++++ 7 files changed, 116 insertions(+) create mode 100644 validation/optim/cmpe-and0.c create mode 100644 validation/optim/cmpe-or0.c create mode 100644 validation/optim/cmps-and0.c create mode 100644 validation/optim/cmps-or0.c create mode 100644 validation/optim/cmps0-and0.c create mode 100644 validation/optim/cmpu-and0.c create mode 100644 validation/optim/cmpu-or0.c diff --git a/validation/optim/cmpe-and0.c b/validation/optim/cmpe-and0.c new file mode 100644 index 000000000000..7db608365568 --- /dev/null +++ b/validation/optim/cmpe-and0.c @@ -0,0 +1,11 @@ +int cmpe_and_eq(int a) { return ((a & 0xff00) == 0xff01) + 1; } +int cmpe_and_ne(int a) { return ((a & 0xff00) != 0xff01) + 0; } + +/* + * check-name: cmpe-and0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/optim/cmpe-or0.c b/validation/optim/cmpe-or0.c new file mode 100644 index 000000000000..bef2316120f7 --- /dev/null +++ b/validation/optim/cmpe-or0.c @@ -0,0 +1,11 @@ +int cmp_eq(int a) { return ((a | 1) != 0) + 0; } +int cmp_ne(int a) { return ((a | 1) == 0) + 1; } + +/* + * check-name: cmpe-or0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/optim/cmps-and0.c b/validation/optim/cmps-and0.c new file mode 100644 index 000000000000..097ec2f9f16c --- /dev/null +++ b/validation/optim/cmps-and0.c @@ -0,0 +1,22 @@ +#define MINUS_ONE -1 +#define MASK 32 + + +int cmps_and_lt_lt0(int a) { return ((a & MASK) < MINUS_ONE) + 1; } +int cmps_and_lt_gtm(int a) { return ((a & MASK) < (MASK + 1)) + 0; } +int cmps_and_le_lt0(int a) { return ((a & MASK) <= MINUS_ONE) + 1; } +int cmps_and_le_gtm(int a) { return ((a & MASK) <= (MASK + 1)) + 0; } + +int cmps_and_gt_lt0(int a) { return ((a & MASK) > MINUS_ONE) + 0; } +int cmps_and_gt_gtm(int a) { return ((a & MASK) > (MASK + 1)) + 1; } +int cmps_and_ge_lt0(int a) { return ((a & MASK) >= MINUS_ONE) + 0; } +int cmps_and_ge_gtm(int a) { return ((a & MASK) >= (MASK + 1)) + 1; } + +/* + * check-name: cmps-and0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/optim/cmps-or0.c b/validation/optim/cmps-or0.c new file mode 100644 index 000000000000..40a2092c58a4 --- /dev/null +++ b/validation/optim/cmps-or0.c @@ -0,0 +1,22 @@ +#define EQ(X) + (X == 0) +#define SIGN (1 << 31) +#define MASK (SIGN | 32) + + +int cmps_ior_lt_x(int a) { return ((a | MASK) < 4) EQ(1); } +int cmps_ior_lt_0(int a) { return ((a | MASK) < 0) EQ(1); } +int cmps_ior_le_x(int a) { return ((a | MASK) <= 4) EQ(1); } +int cmps_ior_le_0(int a) { return ((a | MASK) <= 0) EQ(1); } +int cmps_ior_ge_x(int a) { return ((a | MASK) >= 4) EQ(0); } +int cmps_ior_ge_0(int a) { return ((a | MASK) >= 0) EQ(0); } +int cmps_ior_gt_x(int a) { return ((a | MASK) > 4) EQ(0); } +int cmps_ior_gt_0(int a) { return ((a | MASK) > 0) EQ(0); } + +/* + * check-name: cmps-or0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/optim/cmps0-and0.c b/validation/optim/cmps0-and0.c new file mode 100644 index 000000000000..819a1dc2a793 --- /dev/null +++ b/validation/optim/cmps0-and0.c @@ -0,0 +1,13 @@ +#define M 32 + +int cmps_and_sle0(int a) { return ((a & M) <= 0) == ((a & M) == 0); } +int cmps_and_sgt0(int a) { return ((a & M) > 0) == ((a & M) != 0); } + +/* + * check-name: cmps0-and + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/optim/cmpu-and0.c b/validation/optim/cmpu-and0.c new file mode 100644 index 000000000000..253212941779 --- /dev/null +++ b/validation/optim/cmpu-and0.c @@ -0,0 +1,18 @@ +#define MASK 32U + + +int cmps_and_ltu_gt(int a) { return ((a & MASK) < (MASK + 1)) + 0; } +int cmps_and_leu_gt(int a) { return ((a & MASK) <= (MASK + 1)) + 0; } +int cmps_and_leu_eq(int a) { return ((a & MASK) <= (MASK + 0)) + 0; } +int cmps_and_geu_gt(int a) { return ((a & MASK) >= (MASK + 1)) + 1; } +int cmps_and_gtu_gt(int a) { return ((a & MASK) > (MASK + 1)) + 1; } +int cmps_and_gtu_eq(int a) { return ((a & MASK) > (MASK + 0)) + 1; } + +/* + * check-name: cmpu-and0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/optim/cmpu-or0.c b/validation/optim/cmpu-or0.c new file mode 100644 index 000000000000..77360d3feb0f --- /dev/null +++ b/validation/optim/cmpu-or0.c @@ -0,0 +1,19 @@ +#define EQ(X) + (X == 0) +#define MASK 32U + + +int cmpu_ior_lt_lt(int a) { return ((a | MASK) < (MASK - 1)) EQ(0); } +int cmpu_ior_lt_eq(int a) { return ((a | MASK) < (MASK )) EQ(0); } +int cmpu_ior_le_lt(int a) { return ((a | MASK) <= (MASK - 1)) EQ(0); } +int cmpu_ior_ge_lt(int a) { return ((a | MASK) >= (MASK - 1)) EQ(1); } +int cmpu_ior_ge_eq(int a) { return ((a | MASK) >= (MASK )) EQ(1); } +int cmpu_ior_gt_lt(int a) { return ((a | MASK) > (MASK - 1)) EQ(1); } + +/* + * check-name: cmpu-or0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ From patchwork Wed Mar 10 21:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD176C4332B for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5F3064FAB for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232502AbhCJWLO (ORCPT ); Wed, 10 Mar 2021 17:11:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233157AbhCJWLD (ORCPT ); Wed, 10 Mar 2021 17:11:03 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60575C061574 for ; Wed, 10 Mar 2021 14:11:03 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id jt13so41987358ejb.0 for ; Wed, 10 Mar 2021 14:11:03 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=MKxt5LUBVm+Q16Mixc+0ghRopZAZs/iOW4EmhpRAzq4=; b=k3a84pw1abqjjdBkc4Ue0tXdTDT7AeoZWHPd1MZnC5G4TVCbYB0D+XAftzfLFH4s29 vXjAfB0Gp1XpXOQxWw0che5wL/wYbgZJXSL+9NPKSHyZvarWQGvkRBG1eCUyDyM9qVZd yUyY4Djno3hbvMNPHyMW07udkHvWvMqb2WvlslJgVYwtoQPeT4mUnDfc8ogArpJRWIH1 +wfMgVD3nSgeOGhobkSoMJvx5XHY0niy+esQ5O2bLFXeDR2vD868yTzyiNMZf80C4MjA 14kf2KmHxcX5q0AYl0csi+Kehl5bnd2mSxOytVw8dNLadAH5XYWjrTJ4RpStOQqo2R05 3HLQ== 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:mime-version:content-transfer-encoding; bh=MKxt5LUBVm+Q16Mixc+0ghRopZAZs/iOW4EmhpRAzq4=; b=EeE+cOo1rodW0Tcn7EjWUMzie65PeoUbuviHeK2epbpvGpmWS+MtmQEF2Daxhc33cm G1KdiVMBYOEJIARX4lS5qts2h+oYtZcDmauDJjShsgb8VTpUhhAvD+ssQ+LTSqIfpi4P UnHNWFPG3rFpw6F7HXzLarT6464Xw8F+ml8yGmTkWtqiDT9UO2qByQtb+YO/Zw1xqbAE e2SheqcZ7qmM+FeVJqGrEQQ8Ek2SrEK/RG99IYHz7wY0IjhSx3qEs7lKleRaRHIINpDh RaoOtZb0pMpMJw8iAahx1uU5ErZ6YPj99/xCizQUj9Q2eZ7zQ2faTZDZ92nIQgDc4Ndj aprA== X-Gm-Message-State: AOAM5312zdTo1mqk0lBdYZHK5B/SHswfhJcIRq+Erys2KvKKxCmdb3Rr 0ml1hny/4944l0zyDECM8Gq6LqIOqCg= X-Google-Smtp-Source: ABdhPJwVzixx5rLF1Sbx6Et6IcyXCCWToEwsczSF9STAnf6BaZc3qIA5Wdio3w1S7qQATv4z2ieE1w== X-Received: by 2002:a17:906:ac6:: with SMTP id z6mr42029ejf.505.1615414262118; Wed, 10 Mar 2021 14:11:02 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:01 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/9] simplify (x & M) cmps C Date: Wed, 10 Mar 2021 22:49:44 +0100 Message-Id: <20210310214950.84192-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- simplify.c | 25 +++++++++++++++++++++++++ validation/optim/cmps-and0.c | 1 - 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 207af8edf28f..90b0c5ba0127 100644 --- a/simplify.c +++ b/simplify.c @@ -1258,6 +1258,31 @@ static int simplify_compare_constant(struct instruction *insn, long long value) src2 = insn->src2; value = src2->value; switch (DEF_OPCODE(def, src1)) { + case OP_AND: + if (!constant(def->src2)) + break; + bits = def->src2->value; + switch (insn->opcode) { + case OP_SET_LE: + value = sign_extend(value, def->size); + if (bits & sign_bit(def->size)) + break; + if (value < 0) + return replace_with_value(insn, 0); + if (value >= (long long)bits) + return replace_with_value(insn, 1); + break; + case OP_SET_GT: + value = sign_extend(value, def->size); + if (bits & sign_bit(def->size)) + break; + if (value < 0) + return replace_with_value(insn, 1); + if (value >= (long long)bits) + return replace_with_value(insn, 0); + break; + } + break; case OP_SEXT: // sext(x) cmp C --> x cmp trunc(C) osize = def->orig_type->bit_size; if (is_signed_constant(value, osize, size)) { diff --git a/validation/optim/cmps-and0.c b/validation/optim/cmps-and0.c index 097ec2f9f16c..962fbd2d29f8 100644 --- a/validation/optim/cmps-and0.c +++ b/validation/optim/cmps-and0.c @@ -15,7 +15,6 @@ int cmps_and_ge_gtm(int a) { return ((a & MASK) >= (MASK + 1)) + 1; } /* * check-name: cmps-and0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 From patchwork Wed Mar 10 21:49:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB5C5C43381 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94A9E64FC9 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbhCJWLO (ORCPT ); Wed, 10 Mar 2021 17:11:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233171AbhCJWLE (ORCPT ); Wed, 10 Mar 2021 17:11:04 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B3F2C061574 for ; Wed, 10 Mar 2021 14:11:04 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id t1so95480eds.7 for ; Wed, 10 Mar 2021 14:11:04 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=AEMYXmUNr/t1XuFCn4KA85j2yUZiAEd59KILiE7RemI=; b=pu91w+OB2fSbcKPsvS9lYPinfxCPak20Xj96HnpZvwwN8ANQAiNwoUYK9KRKRI+9se gyo+P9D6xEFPtdRQy1/ip40VQrD4UChpZPMI22AnTKXbKP45wAwngsP4IxhMp/jMWXKs Kaz26mt8w0zXBfhqQ1aWLJDQ/9I6DUwX0WDYVgZin8jALHMO7ksSF3N5Vw8XafYT6kXs FqL4/7Xv2Gg6xNNtx+2DcLcPgJAYdUJOHHWMktTEsR3uyg6jcp3bBnVhRGAqmIZsUVIq g3ef8HEACY8iyFCyOCgojngbnOKWqauVBsp8n7fNZEfDdCugeuM56Kufx70wTQ72NBjl 16UQ== 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:mime-version:content-transfer-encoding; bh=AEMYXmUNr/t1XuFCn4KA85j2yUZiAEd59KILiE7RemI=; b=sLc565BdmztYfrudrcmGWr3f+6bdwZEHBCPq4089+xVK/UnW/tv5MaFS5Uwz1sxibb 3VElV4FasHbcuNEU5PllyvcG4XV0YhsPyY3tifsp9LV+cHVdDu7gWUXluZ+Dvl2aghzx yWf/hzpSl+42sQIvX7EPsthjEh/DkIz2g34jFlWGB2oBC3yxDjri1MLp0il6lVFO3SJz uwff9NW333DeZvaiA2GcH0IJlpjHMOoTkcwYaAsOEpG+f1BsJf6XKOyoHX2N69o01lZh V9P+q96GMyQxDFat+urECZp5H1gWZYVBJXtwYGsCavg3zM27OivgHJfNVZ6eW19p4vup 12jw== X-Gm-Message-State: AOAM5307lTu+afnGVuowYw+QSsqlsRpiNgbM9koIGqHjVWXd9OjYmIEm dHxInpE+JXyr0yP0rNcoFRMstFvJvFI= X-Google-Smtp-Source: ABdhPJzDUySDnNp2XfUEWE4RTk2B1x9VRmoznlaRx+wutGVqtbCULSV7hJwvVT1a2+DaNJIGIxJ2nw== X-Received: by 2002:a50:f391:: with SMTP id g17mr5567955edm.26.1615414263010; Wed, 10 Mar 2021 14:11:03 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:02 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 4/9] simplify (x & M) cmpu C Date: Wed, 10 Mar 2021 22:49:45 +0100 Message-Id: <20210310214950.84192-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- simplify.c | 16 ++++++++++++++++ validation/optim/cmpu-and0.c | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 90b0c5ba0127..ee29c9619bdc 100644 --- a/simplify.c +++ b/simplify.c @@ -1281,6 +1281,22 @@ static int simplify_compare_constant(struct instruction *insn, long long value) if (value >= (long long)bits) return replace_with_value(insn, 0); break; + case OP_SET_B: + if (value > bits) + return replace_with_value(insn, 1); + break; + case OP_SET_BE: + if (value >= bits) + return replace_with_value(insn, 1); + break; + case OP_SET_AE: + if (value > bits) + return replace_with_value(insn, 0); + break; + case OP_SET_A: + if (value >= bits) + return replace_with_value(insn, 0); + break; } break; case OP_SEXT: // sext(x) cmp C --> x cmp trunc(C) diff --git a/validation/optim/cmpu-and0.c b/validation/optim/cmpu-and0.c index 253212941779..927b9fb65f52 100644 --- a/validation/optim/cmpu-and0.c +++ b/validation/optim/cmpu-and0.c @@ -11,7 +11,6 @@ int cmps_and_gtu_eq(int a) { return ((a & MASK) > (MASK + 0)) + 1; } /* * check-name: cmpu-and0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 From patchwork Wed Mar 10 21:49:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2BFFC433E0 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 846B164DE5 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232991AbhCJWLO (ORCPT ); Wed, 10 Mar 2021 17:11:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233258AbhCJWLF (ORCPT ); Wed, 10 Mar 2021 17:11:05 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 218FBC061574 for ; Wed, 10 Mar 2021 14:11:05 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id ci14so41810139ejc.7 for ; Wed, 10 Mar 2021 14:11:05 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=hSOlVvhpswOd0XzkaKOLANb7F+1Hjr1lBL8ZmMILtMo=; b=ooV70CbWoTAtdl9a7hzjrPFYZemf48JETSHY/YdqsbsGioe/sfX3w+SlTYvCFncjQH I53in//WO2csZK1Rz2jUsKz1gkuHY/k6hg6a3j2bJIPyjRUJWlDPGocgeEK5GeMA60nk 5bvnQ985M2N5YSoMEIiCMJuwxHTve2cWlOLbm2DPBxYCeytGpT+bUx8H7tMIonyEAlLb 5wKXBgSKb/RLsHNPkgKEOHGsm0wIh6rR0PSB2uCr6pld2rq9KONDwAKlz278vgkRrgje DRF80JFV5QDpKVV2v4de7RGIOUvPY80h2bvXLXDkRJjWeSD+TNkgv7I+j1pKKSrDZNDi vABw== 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:mime-version:content-transfer-encoding; bh=hSOlVvhpswOd0XzkaKOLANb7F+1Hjr1lBL8ZmMILtMo=; b=e+oC+wmMtkQqZWcyBJN7j0lxL+43eAx6CIi/J97jKh75ZZMG6U66K49vYiG0m7gvk4 nFmHePtJQxP61jQ5pI4Wp/cCgS8TtcpxdMY0b9vOd44hLrYcqMKn1ZGrq3rPOi8wRiDH hxcl0++YyELf6tmiP4fSmbKENs97GI9GNESGa8iq6yuFDwXg+VgHOpDx4JBQdzGkSmLp DqRXhmMNthNj9LnhGdYQqVKbZRJK6My84PZioFeFew+QwgkwSKGyg4bRMPCGa6R51tZ/ ywAJ4ATpcYjgT6b4hFRXUh1gJlC5ffD3qd0n3sfAxTQQTnGTUHhMt3cPDa0iuwLOh4B0 kyjA== X-Gm-Message-State: AOAM532fuBiqfeaU1Zhy0BQWy/Fkgzhdjm4oyvQfy0LdXN16chCZ5v/0 oy3jX0Gx58CNTXDaKY0LTXx/2BFoTR8= X-Google-Smtp-Source: ABdhPJzNRPnZPa0smfKxVnKuGd+lkMIx4l/L4gYV15sq+iZJ3/mkxVbLgV6HfsXd3alHRHupZbHCcQ== X-Received: by 2002:a17:906:f9db:: with SMTP id lj27mr48648ejb.399.1615414263882; Wed, 10 Mar 2021 14:11:03 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:03 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 5/9] simplify (x & M) cmps 0 Date: Wed, 10 Mar 2021 22:49:46 +0100 Message-Id: <20210310214950.84192-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- simplify.c | 4 ++++ validation/optim/cmps0-and0.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index ee29c9619bdc..6c11018ea3bf 100644 --- a/simplify.c +++ b/simplify.c @@ -1271,6 +1271,8 @@ static int simplify_compare_constant(struct instruction *insn, long long value) return replace_with_value(insn, 0); if (value >= (long long)bits) return replace_with_value(insn, 1); + if (value == 0) + return replace_opcode(insn, OP_SET_EQ); break; case OP_SET_GT: value = sign_extend(value, def->size); @@ -1280,6 +1282,8 @@ static int simplify_compare_constant(struct instruction *insn, long long value) return replace_with_value(insn, 1); if (value >= (long long)bits) return replace_with_value(insn, 0); + if (value == 0) + return replace_opcode(insn, OP_SET_NE); break; case OP_SET_B: if (value > bits) diff --git a/validation/optim/cmps0-and0.c b/validation/optim/cmps0-and0.c index 819a1dc2a793..8316916abc8c 100644 --- a/validation/optim/cmps0-and0.c +++ b/validation/optim/cmps0-and0.c @@ -6,7 +6,6 @@ int cmps_and_sgt0(int a) { return ((a & M) > 0) == ((a & M) != 0); } /* * check-name: cmps0-and * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 From patchwork Wed Mar 10 21:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E2FBC43331 for ; Wed, 10 Mar 2021 22:11:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B23364FC3 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233157AbhCJWLP (ORCPT ); Wed, 10 Mar 2021 17:11:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233427AbhCJWLG (ORCPT ); Wed, 10 Mar 2021 17:11:06 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6DA0C061574 for ; Wed, 10 Mar 2021 14:11:05 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id ci14so41810198ejc.7 for ; Wed, 10 Mar 2021 14:11:05 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=CslCwwl1gY0nUwzFdQ+AlQKchoWTYgXm2OAEpGum/h8=; b=CCx4X/cdBnC43HNa2rBrLDB/hWu/XNovBa/Q6Z+CUiy0audtvkEPYFtnWoH0UI++8I U9B8xmY5lt19Rj9s0t/4O/8b7JCW+4kmIBlkztr6ZYwY3iUtw1ziACmKZk7CehRIdSon t/IkmAqhsKFk32fazFWtxM+SL6X/L54WPS2WfLUGCuXN31I5IFI7uys6FncqakKuaEuH EpR27BBUbBJZbnd3TmbgYD4R0io7kSyn3xkoAK2pbD8HEUqmFCcpuwafjuD9xQGjEgli zQoWji2cBXHidQUVBlOenbJgHZKUfD8XpuzojKa6YD4JL1CkEwEK3jgjVJzjJDayoQJ6 5phQ== 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:mime-version:content-transfer-encoding; bh=CslCwwl1gY0nUwzFdQ+AlQKchoWTYgXm2OAEpGum/h8=; b=To5+QvCAWE96SrjaPJ+RnI4FD5wKTPwN6xr/Y2z+DK26jydn2Vp6J9VnqrmL/rjUwJ d0qKjiYuQJzWL3xlwh9rAJEjAUF9IKV4itDn8tfXLBpQm5UE+VDTc36CShN4x5Nh804A 8FC0xO0/d30DsEHnju+y5zrk/5d/3mPTRgyrYU+uUxadt84qs//Z7+Pi+6fAw5P0eiKd Ctob23Dj7DXTJuxv2s1PzzE61Vb9HGBDWe6mF32Dm3fxoFOMC3TcZnvovD7EFf4QJ8bc hiNCuptb+gn1SZu4jyZezINbAWkmItgXaqUEfPS3vqhzHMWcmH2st4EUAP+M5dUwcHMA meKQ== X-Gm-Message-State: AOAM531xl60texfeecbA4gkLbsisR2SjzqaH0ObhMmTFfGxo4Q/Kvmfl 0bEGHLxMGyWP6x1KHYtzOP3w8PtjNjU= X-Google-Smtp-Source: ABdhPJypEDH1O+FN7FWZO22WogjgBhVQLZK7Ppkn0Sez7qQ1VQCEZ5fIndDT/gRXOfozl0Rsox4OXQ== X-Received: by 2002:a17:906:6817:: with SMTP id k23mr89079ejr.6.1615414264641; Wed, 10 Mar 2021 14:11:04 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:04 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 6/9] simplify (x & M) {==,!=} C Date: Wed, 10 Mar 2021 22:49:47 +0100 Message-Id: <20210310214950.84192-7-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- simplify.c | 8 ++++++++ validation/optim/cmpe-and0.c | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 6c11018ea3bf..b46e08c3b79a 100644 --- a/simplify.c +++ b/simplify.c @@ -1263,6 +1263,14 @@ static int simplify_compare_constant(struct instruction *insn, long long value) break; bits = def->src2->value; switch (insn->opcode) { + case OP_SET_EQ: + if ((value & bits) != value) + return replace_with_value(insn, 0); + break; + case OP_SET_NE: + if ((value & bits) != value) + return replace_with_value(insn, 1); + break; case OP_SET_LE: value = sign_extend(value, def->size); if (bits & sign_bit(def->size)) diff --git a/validation/optim/cmpe-and0.c b/validation/optim/cmpe-and0.c index 7db608365568..75af77528f61 100644 --- a/validation/optim/cmpe-and0.c +++ b/validation/optim/cmpe-and0.c @@ -4,7 +4,6 @@ int cmpe_and_ne(int a) { return ((a & 0xff00) != 0xff01) + 0; } /* * check-name: cmpe-and0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 From patchwork Wed Mar 10 21:49:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32E32C43333 for ; Wed, 10 Mar 2021 22:11:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A5F764FAB for ; Wed, 10 Mar 2021 22:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233131AbhCJWLO (ORCPT ); Wed, 10 Mar 2021 17:11:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233450AbhCJWLG (ORCPT ); Wed, 10 Mar 2021 17:11:06 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C7AC061574 for ; Wed, 10 Mar 2021 14:11:06 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id b13so143441edx.1 for ; Wed, 10 Mar 2021 14:11:06 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=XRz/c+V0KLbt7rcYnVpHcsX3x3H0fM14HqWzYEQ8oos=; b=rkQQfkapgcQ5QTQNYe35hALGVrVB2xHTt6C8ZGzfG0RuJZi9Y26hCb0JkO2wQ01rjT aVQ2a5AzLK05ajLz3ka6khGA+yY5uhHrLA+R9wzIrQslvcISmI8cZFzHp50woSiO1PVm NCddHr4mD5nWKxHBrJ63o4iz48WGrMLBfG506LnL3hx22Pz5TZABCj77+yBd03/BmNyK BFzuc8Xd++ZaGSVlTJMHRrKMdX7wB2GHXtbbWfT+6GrfLxwrJ+wWnLVM0/o2xN52O3x8 USyS27bM5/FBVsJNW0P5X9ULDeokrx/df+Kv7N441I/gBInSpmTGmZL301UF2+DWuRzZ 71pw== 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:mime-version:content-transfer-encoding; bh=XRz/c+V0KLbt7rcYnVpHcsX3x3H0fM14HqWzYEQ8oos=; b=hHb2U4cg8TLtBZWhmhNNXUIkUCQWev7UmtCAtncD5arJIuTD0I8yrOjzaLglCHhWZZ OfT+sC5NcOtfYZ2MOvT6U8GyiTBgoxc2MmyH13+GFgLwYuG7kDJ3xHUNvnLkKedfIIld rGo9Gj2I2GcqZPYuhU6NHZqxGPgK5TiPGlQBSxaxDUlTfaJlLpQls87OBCIiVh5eXMbb PBADEF8nrjFkLO7CLSVpCn6glceUIZvbEIClUu6ZpQLjHYAn3z1tvNRoFjmqEbwWoYoN tGLjPNUNdezIRRvwSU9JrYTXt5ey3l0Otg4M81LXtb1698kipw25qYSXlCmG5kpYFknm byDw== X-Gm-Message-State: AOAM531G+bLTySh9U3I5Iy6JWJtLmvP12abygDFhP5hZVYwYDoi4km3N jj1915dnwXGA36TEPwjNGWTKCJPJ16k= X-Google-Smtp-Source: ABdhPJyspMtoBDhfy40vij6VvgoZ9NzRvRMeh6O1AE6TOLJTxmDiEu19X2xsEF2OvHWVBTbNuq6WOQ== X-Received: by 2002:aa7:d987:: with SMTP id u7mr5500081eds.326.1615414265277; Wed, 10 Mar 2021 14:11:05 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:04 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 7/9] simplify (x | M) {==,!=} C Date: Wed, 10 Mar 2021 22:49:48 +0100 Message-Id: <20210310214950.84192-8-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- simplify.c | 15 +++++++++++++++ validation/optim/cmpe-or0.c | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index b46e08c3b79a..865fadfb590e 100644 --- a/simplify.c +++ b/simplify.c @@ -1311,6 +1311,21 @@ static int simplify_compare_constant(struct instruction *insn, long long value) break; } break; + case OP_OR: + if (!constant(def->src2)) + break; + bits = def->src2->value; + switch (insn->opcode) { + case OP_SET_EQ: + if ((value & bits) != bits) + return replace_with_value(insn, 0); + break; + case OP_SET_NE: + if ((value & bits) != bits) + return replace_with_value(insn, 1); + break; + } + break; case OP_SEXT: // sext(x) cmp C --> x cmp trunc(C) osize = def->orig_type->bit_size; if (is_signed_constant(value, osize, size)) { diff --git a/validation/optim/cmpe-or0.c b/validation/optim/cmpe-or0.c index bef2316120f7..2e89d611117d 100644 --- a/validation/optim/cmpe-or0.c +++ b/validation/optim/cmpe-or0.c @@ -4,7 +4,6 @@ int cmp_ne(int a) { return ((a | 1) == 0) + 1; } /* * check-name: cmpe-or0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 From patchwork Wed Mar 10 21:49:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 108EEC4332D for ; Wed, 10 Mar 2021 22:11:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E50BD64DE5 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233171AbhCJWLP (ORCPT ); Wed, 10 Mar 2021 17:11:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233528AbhCJWLH (ORCPT ); Wed, 10 Mar 2021 17:11:07 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D74AC061574 for ; Wed, 10 Mar 2021 14:11:07 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id b7so86595edz.8 for ; Wed, 10 Mar 2021 14:11:07 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=FNbUUObvWvj/wnufy2aMSRBmJG00h2J6KXs/pLxUg1M=; b=EeXuiWL1RqKIxn7HUJrFvWQ3RKfrIYNX1PE4lIZMiDZpLnba09momZT7F4ialCH7WK eHLuGWSy/JFF4RurC/6O/OIzsGpTMXjMd0yerWymAFUIMFg0CvZKSta0WX8Ux6TOFiiE 0uem6gN7+GmHtBxe1oaI1NBQEICngnU/cbSGg+lCHcOVM0CRh0tkR/rusILluCcEf2F4 VMgU5CZxIb+4fQy1k0N6IqX5/FNHQ25f5HlEN8uvHflCk+AQBiY+pOEoJenqZPrAqz4/ 0SwfPpbpuviTtRY8xckSUVPwXyupnQPD3hSRpR+mV1uDWRFo1/QwkVBiOVgwRuTm2pcQ NOQg== 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:mime-version:content-transfer-encoding; bh=FNbUUObvWvj/wnufy2aMSRBmJG00h2J6KXs/pLxUg1M=; b=hHsaaVMCQwfo1La2Jn419f9wbWoKodjcKfV9dF9f5TKVGdy5uxv1V0iiRmoP7VGwP4 zYo6YEbq8ZHSQXYB1dTWDgC1en2q6nMXasi0Q4aRfVisPss9wxPHZY8gGVaRGYrzDBKq wdlkqT00Z6U6ZA3bhmvUc8K/8M2D5S8WKfaGwX9GRChybbT1qvfEGRrXq+Hpx0J9wEJf 6OLoQLU+vpET7zNyrydq52wmVKfVFDBalOosI5fxziK61aGOl5XKJxQ9jDTj8a6vZ2TK he0LBZkb50dE2620Qo5lISaZLTWhTMums+M/jS6tr7b0u31Ic8QnUi0/PB6kfU9wzDOB 1w+Q== X-Gm-Message-State: AOAM530tsVX0OM77YNZUUof6Hzkyie4N/BMHFCe3EEE0N6zlsTB+KM1l 02E/l72M31J6kwjlySSTjJZEBcsXMd0= X-Google-Smtp-Source: ABdhPJzNEOy2tb8AVyGiVSXuIiXjfzDRKwUTxlaOh+75VrdS7ZVm7gUDcejMr5rmIFYBcSy+H3GGIA== X-Received: by 2002:aa7:d656:: with SMTP id v22mr5461050edr.119.1615414265955; Wed, 10 Mar 2021 14:11:05 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:05 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 8/9] simplify (x | M) cmps C Date: Wed, 10 Mar 2021 22:49:49 +0100 Message-Id: <20210310214950.84192-9-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- simplify.c | 14 ++++++++++++++ validation/optim/cmps-or0.c | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 865fadfb590e..e721f9f860a0 100644 --- a/simplify.c +++ b/simplify.c @@ -1324,6 +1324,20 @@ static int simplify_compare_constant(struct instruction *insn, long long value) if ((value & bits) != bits) return replace_with_value(insn, 1); break; + case OP_SET_LE: + value = sign_extend(value, def->size); + if (bits & sign_bit(def->size)) { + if (value >= -1) + return replace_with_value(insn, 1); + } + break; + case OP_SET_GT: + value = sign_extend(value, def->size); + if (bits & sign_bit(def->size)) { + if (value >= -1) + return replace_with_value(insn, 0); + } + break; } break; case OP_SEXT: // sext(x) cmp C --> x cmp trunc(C) diff --git a/validation/optim/cmps-or0.c b/validation/optim/cmps-or0.c index 40a2092c58a4..70fcb024a846 100644 --- a/validation/optim/cmps-or0.c +++ b/validation/optim/cmps-or0.c @@ -15,7 +15,6 @@ int cmps_ior_gt_0(int a) { return ((a | MASK) > 0) EQ(0); } /* * check-name: cmps-or0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 From patchwork Wed Mar 10 21:49:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12129631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E26BAC433E9 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFBCA64FC6 for ; Wed, 10 Mar 2021 22:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233209AbhCJWLP (ORCPT ); Wed, 10 Mar 2021 17:11:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233489AbhCJWLI (ORCPT ); Wed, 10 Mar 2021 17:11:08 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16AFC061574 for ; Wed, 10 Mar 2021 14:11:07 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id l12so127338edt.3 for ; Wed, 10 Mar 2021 14:11:07 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=WukwxrAgEZQS4XHFx5UY3Y0yVGYgz54qpKrVcDNDIU0=; b=px/cFI9ENfwQp81X4qc2g/cPjFONSAhvxzNzE1bH0z8NBEwOEcZ5cnTTFYb+kMGib2 OHKvr8eGedScoMl1LDceRypP1AwAuNKpadUdgpWX/c361dlThm53FLb7pdO8hPKH4T2W 4uf2g/Jrp58tKsff/7BzhQQQ5Z+VGLIyWjuIYw3oely2CEm3Idx5ciZx/+Fi2YFlTU9e btT/ZT/KMI/+W7NnIz1pRYsKgPRKdw9GpJWCnsQB0SIJktpwICfCUAPlXyMqG9d3ukp7 tipGMUIQYQ54ydmBbWQEctinpVPYjWNC3Rc4vDQ20ylj1kCs6KNjzuC38FBVt5Qku8hQ Aylw== 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:mime-version:content-transfer-encoding; bh=WukwxrAgEZQS4XHFx5UY3Y0yVGYgz54qpKrVcDNDIU0=; b=T6OLyBssru5G5hobbb8rwZbi7oeGyv+6HDdhoLRKzctWd4Ry6DstzKA3xpthizq1kd 6WwIE5fnXbq6XyB0Pxhq0wAreeVyNsGS49oV2bBCDMGfA/J+JuQX3lCfZgT0dFqxoO1s nEYt5cFmy6rf/Aw4cCksNavciMS3qWxgz0p6ynZ8n10Esyhe5vRp71CJ0OdXaYysRJa/ HbTsUYRXBacnJYrqok561cxHcmfuS00fTM9SQqCAqDs3H1FJuRonEyiiUdFRKT37uY6+ dFCZPJ1tllvTG38EPxxpmhrkFRdKRtGoC6DgHFfcZxJLHwxVUFu0V/OvFnhOcAnSGx2n LWCQ== X-Gm-Message-State: AOAM5305XF5rvaLaiTwRIkNKFn0MWUIvlGuHkRVTEorxmeP0XRV9lS4D Vh5WdwhZ3rEvODk745jwC0Em8NzANGA= X-Google-Smtp-Source: ABdhPJzF9ipOL1aBwe7Qjp7i/zmKQCHevFwxEiMBxo4cg1GpaOk2t25W188BFv1Wqs3iIwJ25QgcKA== X-Received: by 2002:a05:6402:22f6:: with SMTP id dn22mr5506909edb.214.1615414266779; Wed, 10 Mar 2021 14:11:06 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:196c:c08:d4ab:a1ba]) by smtp.gmail.com with ESMTPSA id ld19sm344326ejb.102.2021.03.10.14.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 14:11:06 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 9/9] simplify (x | M) cmpu C Date: Wed, 10 Mar 2021 22:49:50 +0100 Message-Id: <20210310214950.84192-10-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> References: <20210310214950.84192-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Signed-off-by: Luc Van Oostenryck --- simplify.c | 16 ++++++++++++++++ validation/optim/cmpu-or0.c | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index e721f9f860a0..9e3514d838a9 100644 --- a/simplify.c +++ b/simplify.c @@ -1324,6 +1324,22 @@ static int simplify_compare_constant(struct instruction *insn, long long value) if ((value & bits) != bits) return replace_with_value(insn, 1); break; + case OP_SET_B: + if (bits >= value) + return replace_with_value(insn, 0); + break; + case OP_SET_BE: + if (bits > value) + return replace_with_value(insn, 0); + break; + case OP_SET_AE: + if (bits > value) + return replace_with_value(insn, 1); + break; + case OP_SET_A: + if (bits >= value) + return replace_with_value(insn, 1); + break; case OP_SET_LE: value = sign_extend(value, def->size); if (bits & sign_bit(def->size)) { diff --git a/validation/optim/cmpu-or0.c b/validation/optim/cmpu-or0.c index 77360d3feb0f..e97e91809461 100644 --- a/validation/optim/cmpu-or0.c +++ b/validation/optim/cmpu-or0.c @@ -12,7 +12,6 @@ int cmpu_ior_gt_lt(int a) { return ((a | MASK) > (MASK - 1)) EQ(1); } /* * check-name: cmpu-or0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1