From patchwork Sun Apr 18 11:56:33 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: 12210045 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 2D020C433ED for ; Sun, 18 Apr 2021 11:56:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 071FC61207 for ; Sun, 18 Apr 2021 11:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbhDRL5N (ORCPT ); Sun, 18 Apr 2021 07:57:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhDRL5N (ORCPT ); Sun, 18 Apr 2021 07:57:13 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FAB0C061760 for ; Sun, 18 Apr 2021 04:56:45 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id w23so32872185ejb.9 for ; Sun, 18 Apr 2021 04:56:45 -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 :mime-version:content-transfer-encoding; bh=NH0LNSWBNR9oDnZxvy31WWrnQiSVgZOVFw7tMgZKXy8=; b=hTP/kZIPzI+Ue92t3QpYpk019fwYfpa/WfaZJwJK1IJZnZfVrhHZnvOegqrRM5PYB9 H4Vw9rlQ5Skr16AfOAtUuItiLYsKE2rkmIZJ9LB6cJtctJL4mUbV5BTm385QuQPTLH0b 0pp/qo2dCkX+QqegPXioGnO7rogFkxi5x/8PDWqgMvJeW3NMcqDjA2+l2lf+0+8zqkds XSK7qCY/SqEo2k5Mu71f6U9baTy49aaYYkjRLdvD1qzYHumI5XJ7ZEqZXHjzS351iahl bz0//ZL/zkTCz1IkiheSi1nB2bAA87QaAoKoUyoSY/aqG/JnvAc8AwJlpGthvJekXlrW 0aGw== 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=NH0LNSWBNR9oDnZxvy31WWrnQiSVgZOVFw7tMgZKXy8=; b=dskyy+CiRhBjL5XBwEb5CxxaE8ZnpOcVBvCU6JcyOyxTc6YfIPpGIQcZSpQoN3P1S4 rs0Xl+0cp0XUY3llaTNDhCCEqjHuZp6/meV5vH4KiC9xXGsjOGjQyCSnjr/r7OS2JiUX pBLT5djJwLPuveSdmJtlxPSO35vm7hZkx0F2Nh+vstRhVvpbmkUe3oc6Rr/Zfddx75o4 3OtKuuu4ZtXFpETFpEZdNRED45NohEkICUyz6Sd03p/+B5y8aCghdtTIdvQu/x++dui6 1QsVKWp4FTcvmgbkQFzLAzkCD/mme3JrDdCRGgg3fdz4SS4csTnshAO7hsaSKJ7xRxeL HyPw== X-Gm-Message-State: AOAM530qZSi9O3AJAlnVo1vI7K/xPaXb25NbUy2++RsscB2ux7mWoBPf nY+h0Y4sXb87l3TMI1urQ/TEQ5m90dA= X-Google-Smtp-Source: ABdhPJwwfaEiqEhcVmqzfcAMGE0rXGJbcoi2vqwKsPqg0UMPlvgvl9T91OE5a5TGql+U3FIH+1VU3Q== X-Received: by 2002:a17:907:9607:: with SMTP id gb7mr16658165ejc.380.1618747003177; Sun, 18 Apr 2021 04:56:43 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:959c:c85:d486:38cf]) by smtp.gmail.com with ESMTPSA id y11sm10298199eds.10.2021.04.18.04.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Apr 2021 04:56:42 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/3] add testcases for simplification of casts. Date: Sun, 18 Apr 2021 13:56:33 +0200 Message-Id: <20210418115635.40608-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210418115635.40608-1-luc.vanoostenryck@gmail.com> References: <20210418115635.40608-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org and remove one that didn't made much sense. Signed-off-by: Luc Van Oostenryck --- validation/eval/not-cast-bool.c | 15 +++++++++++++++ validation/eval/not-cast-float.c | 15 +++++++++++++++ validation/optim/and-extendx.c | 24 ------------------------ validation/optim/trunc-not0.c | 21 +++++++++++++++++++++ 4 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 validation/eval/not-cast-bool.c create mode 100644 validation/eval/not-cast-float.c delete mode 100644 validation/optim/and-extendx.c create mode 100644 validation/optim/trunc-not0.c diff --git a/validation/eval/not-cast-bool.c b/validation/eval/not-cast-bool.c new file mode 100644 index 000000000000..af4224125c34 --- /dev/null +++ b/validation/eval/not-cast-bool.c @@ -0,0 +1,15 @@ +static _Bool foo(void) +{ + unsigned char c = 1; + _Bool b = ~c; + return b; +} + +/* + * check-name: not-cast-bool + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/eval/not-cast-float.c b/validation/eval/not-cast-float.c new file mode 100644 index 000000000000..445b91d7563e --- /dev/null +++ b/validation/eval/not-cast-float.c @@ -0,0 +1,15 @@ +static int foo(void) +{ + int i = 123; + float x = ~i; + return (x < 0); +} + +/* + * check-name: eval-bool-zext-neg + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ diff --git a/validation/optim/and-extendx.c b/validation/optim/and-extendx.c deleted file mode 100644 index 5c181c93384e..000000000000 --- a/validation/optim/and-extendx.c +++ /dev/null @@ -1,24 +0,0 @@ -typedef unsigned short u16; -typedef short s16; -typedef unsigned int u32; -typedef int s32; -typedef unsigned long long u64; -typedef long long s64; - -u64 ufoo(int x) -{ - return x & 0x7fff; -} - -u64 sfoo(int x) -{ - return x & 0x7fff; -} - -/* - * check-name: and-extend - * check-command: test-linearize -Wno-decl $file - * - * check-output-ignore - * check-output-contains: and\\.64.*0x7fff - */ diff --git a/validation/optim/trunc-not0.c b/validation/optim/trunc-not0.c new file mode 100644 index 000000000000..febed165b0c4 --- /dev/null +++ b/validation/optim/trunc-not0.c @@ -0,0 +1,21 @@ +typedef __INT32_TYPE__ int32; +typedef __INT64_TYPE__ int64; + +static _Bool sfoo(int64 a) { return ((int32) ~a) == (~ (int32)a); } +static _Bool sbar(int64 a) { return (~(int32) ~a) == (int32)a; } + + +typedef __UINT32_TYPE__ uint32; +typedef __UINT64_TYPE__ uint64; + +static _Bool ufoo(uint64 a) { return ((uint32) ~a) == (~ (uint32)a); } +static _Bool ubar(uint64 a) { return (~(uint32) ~a) == (uint32)a; } + +/* + * check-name: trunc-not0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-returns: 1 + */ From patchwork Sun Apr 18 11:56:34 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: 12210047 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 AF597C43460 for ; Sun, 18 Apr 2021 11:56:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8398761207 for ; Sun, 18 Apr 2021 11:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbhDRL5O (ORCPT ); Sun, 18 Apr 2021 07:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbhDRL5O (ORCPT ); Sun, 18 Apr 2021 07:57:14 -0400 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 0C96CC06174A for ; Sun, 18 Apr 2021 04:56:45 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id j12so12358758edy.3 for ; Sun, 18 Apr 2021 04:56:44 -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 :mime-version:content-transfer-encoding; bh=AAVEv80tdd2CseM46A14LcW48P4xCQ/gB5to14QQkuQ=; b=EB8aFIYrTwg9M6PYjz6isOkU7cS4FeMepjgF/VAR3ETOC27JOX1/AhwbOeAI1izoeI 1sq5AzKWWxkERFvDUxVEqpiwpN6hVSyb8uHFgAPNw411+3FDQtajgih5p694RHUkdXDL BHJ02Tsx5qfjSiHgM3E1sXNaXCxy/TzJWDopMJlGhwUG5YG4k0AKGDK0K6ZR0PoqpIEq gihYzhpwoXzigdVVxqTjimXxBlKLPbiw7FOlSjTFuopp6t23kyBk4k+nScXOfO79SKSH CWA7KpN6AS26/OHSTdt2ovHG6L80CvP5DPGGZIbjx6nuJHnnJyevm+PiTsp8jf6xZp5c Dk5w== 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=AAVEv80tdd2CseM46A14LcW48P4xCQ/gB5to14QQkuQ=; b=Wh9A66cSXXGN63iGIln5+4oERh5wt58XUl9H/RLEgMxda6ghRDF95oESx2IBi0LHAf l9vMsaUHUxvnKbVaIHpLu+iYW4cFSTJWadlJiBn/S2Fq4Tk0dloJTpnJ+XlpRpzqjO51 6MouzaGbOFyGBKw8+H+ZgE2mM8epHGMYEk/ba2HbIjzfv4qf/KG/6obiU2J88bvObHCQ wWdhnWsWG8sjAF5WotqC1efkLBz4cTE8zk7M4ETRjoHTVYJsXv68k0BHEBDbCf7NWaFM gXck7mNcaYd9P8NZXcCSyUTlJdBf0whdHdCPo1SqropjB7XfDJLOkzpJwH9mbJEQOomD bRXQ== X-Gm-Message-State: AOAM530kP+TkQf6e+pvKeCQlmnymbbxL0KpBtSneJS9tvPZccDiIFOhQ UWqHbCFZYIpoMbdAYlK6J6zjOS8K85c= X-Google-Smtp-Source: ABdhPJxMID0OhFW+hyCIcwgPiXk78qmR5L4YuiLmtyEN4TGeoAVJuQ7hJUrMf2M+KCFhhvCOx/Qjeg== X-Received: by 2002:aa7:dd4d:: with SMTP id o13mr20468572edw.53.1618747003826; Sun, 18 Apr 2021 04:56:43 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:959c:c85:d486:38cf]) by smtp.gmail.com with ESMTPSA id y11sm10298199eds.10.2021.04.18.04.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Apr 2021 04:56:43 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/3] simplify TRUNC(NOT(x)) --> NOT(TRUNC(x)) Date: Sun, 18 Apr 2021 13:56:34 +0200 Message-Id: <20210418115635.40608-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210418115635.40608-1-luc.vanoostenryck@gmail.com> References: <20210418115635.40608-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The goal is double: 1) be able to do the NOT operation on the smaller type 2) more importantly, give the opportunity to the TRUNC to cancel with a previous ZEXT if there is one. Signed-off-by: Luc Van Oostenryck --- simplify.c | 15 +++++++++++++++ validation/optim/trunc-not0.c | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 9e3514d838a9..b2311d397b23 100644 --- a/simplify.c +++ b/simplify.c @@ -2288,6 +2288,21 @@ static int simplify_cast(struct instruction *insn) return replace_pseudo(insn, &insn->src1, def->src1); } break; + case OP_NOT: + switch (insn->opcode) { + case OP_TRUNC: + if (!one_use(src)) + break; + + // TRUNC(NOT(x)) --> NOT(TRUNC(x)) + insn->opcode = OP_NOT; + def->orig_type = def->type; + def->opcode = OP_TRUNC; + def->type = insn->type; + def->size = insn->size; + return REPEAT_CSE; + } + break; case OP_OR: switch (insn->opcode) { case OP_TRUNC: diff --git a/validation/optim/trunc-not0.c b/validation/optim/trunc-not0.c index febed165b0c4..882b446d9197 100644 --- a/validation/optim/trunc-not0.c +++ b/validation/optim/trunc-not0.c @@ -14,7 +14,6 @@ static _Bool ubar(uint64 a) { return (~(uint32) ~a) == (uint32)a; } /* * check-name: trunc-not0 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 From patchwork Sun Apr 18 11:56:35 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: 12210049 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 7B8E6C433B4 for ; Sun, 18 Apr 2021 11:56:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D338610CC for ; Sun, 18 Apr 2021 11:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbhDRL5O (ORCPT ); Sun, 18 Apr 2021 07:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhDRL5O (ORCPT ); Sun, 18 Apr 2021 07:57:14 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6FBAC061760 for ; Sun, 18 Apr 2021 04:56:45 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id s15so37397205edd.4 for ; Sun, 18 Apr 2021 04:56:45 -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 :mime-version:content-transfer-encoding; bh=07eS4yBn68wirJHAnWcxwjAWX50yqzrbmIiZnhblOAs=; b=HFcoqCOPbdsLRDL5tgtKPiBRgFchZBwsmMRA/IpGoCpBe5obDs9oymOGvwIv+lMuaV KZoMh/mZvv09dSsMAAounz44qJQXsjAwZJnwcdOw85w95hpyYzIHO9OBW8pPJPZbrXQw 7QkOxtpOmwjE6tNJhLtITQszSopD6pP01RdlpCgkwRz00ZVKUjMyGxGDE6U06EgsXAKh rAng+ickF1nRtv7GVNJ1E7U/Cc99ZWMDhXeuW61qFaYK224E+jEzT4Oz4WQJtbK929kg QWmXes8j4uBjheCdnDTSJSETJytY36PTM7M7HiJjY16iM9WWLlJE3AWqY9YHIa/A+xyZ eMXw== 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=07eS4yBn68wirJHAnWcxwjAWX50yqzrbmIiZnhblOAs=; b=Ah58kNKioywtSqbGG78b4LBSm8b0S28Mndy+Ly5Ng/KQ3wWZeyO5Gb5sTNdb8NIkDG MWmsQUKsClluwugX4svBxaTuLdcN9+vvpC6N/rz/j1MYrpIk4NlYxkFHE7eaRkwdHtGm 4pNsb6GaHvOSiulVt5lj9icCzgVfcCxyZSjnZePLUy3amSj8R4rlVsMR6PC1umcUomNK rn9n8xhmYTfmoHs3P6o+FLBG2Q3KMunOJGY1c7S2hmwVxcl4QjATMyWP2n1bNsua/nx9 Bs7SUPXqc2XO16jjOzFtN1Cc6YAq1vyiO4SHeueKhhIU7l9Dv6MQ+w31UrCb8K8Tbg4x ewXg== X-Gm-Message-State: AOAM5315g+tJIJDpulxgZZiwvbric9PUbKd/t7HfVw9i3nEahq86VelC mX5rJlkepWtDdkwmvL60pYBAnSDAyTg= X-Google-Smtp-Source: ABdhPJz2rK66E9KMlcmAgiirhdub/oXl0ImDPclvPOgeX4EAAOsyxWFotiD06v+qR/a9SgKSDyvAhQ== X-Received: by 2002:aa7:c40b:: with SMTP id j11mr20157244edq.219.1618747004539; Sun, 18 Apr 2021 04:56:44 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:959c:c85:d486:38cf]) by smtp.gmail.com with ESMTPSA id y11sm10298199eds.10.2021.04.18.04.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Apr 2021 04:56:44 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/3] remove early simplification of casts during evaluation Date: Sun, 18 Apr 2021 13:56:35 +0200 Message-Id: <20210418115635.40608-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210418115635.40608-1-luc.vanoostenryck@gmail.com> References: <20210418115635.40608-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The current code will simplify away some casts at evaluation time but doesn't take in account some special cases: * (bool)~ is not equivalent to ~(bool) (anything not all 0 or 1) * (float)~ is not equivalent to ~(float) which doesn't make sense. * (int)(float) is not a no-op if the (float) overflows This kind of simplification is better done on the IR where the different kind of casts correspond to distinct instructions. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 44 +------------------------------- validation/eval/not-cast-bool.c | 1 - validation/eval/not-cast-float.c | 1 - 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/evaluate.c b/evaluate.c index eea6b7adcf64..61f59ee3908e 100644 --- a/evaluate.c +++ b/evaluate.c @@ -226,12 +226,6 @@ static struct symbol *bigger_int_type(struct symbol *left, struct symbol *right) return utype; } -static int same_cast_type(struct symbol *orig, struct symbol *new) -{ - return orig->bit_size == new->bit_size && - orig->bit_offset == new->bit_offset; -} - static struct symbol *base_type(struct symbol *node, unsigned long *modp, struct ident **asp) { unsigned long mod = 0; @@ -316,10 +310,7 @@ static struct symbol *cast_to_bool(struct expression *expr); /* * This gets called for implicit casts in assignments and - * integer promotion. We often want to try to move the - * cast down, because the ops involved may have been - * implicitly cast up, and we can get rid of the casts - * early. + * integer promotion. */ static struct expression * cast_to(struct expression *old, struct symbol *type) { @@ -330,39 +321,6 @@ static struct expression * cast_to(struct expression *old, struct symbol *type) if (old->ctype != &null_ctype && is_same_type(old, type)) return old; - /* - * See if we can simplify the op. Move the cast down. - */ - switch (old->type) { - case EXPR_PREOP: - if (old->ctype->bit_size < type->bit_size) - break; - if (old->op == '~') { - old->ctype = type; - old->unop = cast_to(old->unop, type); - return old; - } - break; - - case EXPR_IMPLIED_CAST: - warn_for_different_enum_types(old->pos, old->ctype, type); - - if (old->ctype->bit_size >= type->bit_size) { - struct expression *orig = old->cast_expression; - if (same_cast_type(orig->ctype, type)) - return orig; - if (old->ctype->bit_offset == type->bit_offset) { - old->ctype = type; - old->cast_type = type; - return old; - } - } - break; - - default: - /* nothing */; - } - expr = alloc_expression(old->pos, EXPR_IMPLIED_CAST); expr->ctype = type; expr->cast_type = type; diff --git a/validation/eval/not-cast-bool.c b/validation/eval/not-cast-bool.c index af4224125c34..acd8bbf293db 100644 --- a/validation/eval/not-cast-bool.c +++ b/validation/eval/not-cast-bool.c @@ -8,7 +8,6 @@ static _Bool foo(void) /* * check-name: not-cast-bool * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1 diff --git a/validation/eval/not-cast-float.c b/validation/eval/not-cast-float.c index 445b91d7563e..d474d69bdda3 100644 --- a/validation/eval/not-cast-float.c +++ b/validation/eval/not-cast-float.c @@ -8,7 +8,6 @@ static int foo(void) /* * check-name: eval-bool-zext-neg * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-returns: 1