From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Ramsay Jones <ramsay@ramsayjones.plus.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 1/3] add more testcases for existing AND/OR simplifications
Date: Sun, 6 Sep 2020 20:52:26 +0200 [thread overview]
Message-ID: <20200906185226.sjfbnuo7dbrfc3dm@ltop.local> (raw)
In-Reply-To: <b699c65e-5173-79dc-3ddb-20242646f0f1@ramsayjones.plus.com>
Hi,
On Sun, Sep 06, 2020 at 05:12:40PM +0100, Ramsay Jones wrote:
> On 06/09/2020 13:40, Luc Van Oostenryck wrote:
> > Add a few more testcases to catch possible future regressions.
> >
> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> > ---
> > validation/optim/and-shl-or-and0.c | 13 +++++++++++++
> > validation/optim/lsr-or-and0.c | 23 +++++++++++++++++++++++
> > validation/optim/shl-or-constant0.c | 12 ++++++++++++
> > validation/optim/shl-or-constant1.c | 12 ++++++++++++
> > validation/optim/shl-or-constant2.c | 12 ++++++++++++
> > 5 files changed, 72 insertions(+)
> > create mode 100644 validation/optim/and-shl-or-and0.c
> > create mode 100644 validation/optim/lsr-or-and0.c
> > create mode 100644 validation/optim/shl-or-constant0.c
> > create mode 100644 validation/optim/shl-or-constant1.c
> > create mode 100644 validation/optim/shl-or-constant2.c
> >
> > diff --git a/validation/optim/and-shl-or-and0.c b/validation/optim/and-shl-or-and0.c
> > new file mode 100644
> > index 000000000000..ea08d2622a95
> > --- /dev/null
> > +++ b/validation/optim/and-shl-or-and0.c
> > @@ -0,0 +1,13 @@
> > +unsigned and_shl_or_and0(unsigned a, unsigned b)
> > +{
> > + return (((a & 0xfff00000) | b) << 12) & 0xfff00000;
>
> ->(((a & 0xfff00000) << 12) | (b << 12)) & 0xfff00000
> ->(( 0 | (b << 12)) & 0xfff00000
> ->((b << 12)) & 0xfff00000
> > +}
> > +
> > +/*
> > + * check-name: and-shl-or-and0
> > + * check-command: test-linearize -Wno-decl $file
> > + *
> > + * check-output-ignore
> > + * check-output-excludes: or\\.
> > + * check-output-excludes: lsr\\.
>
> why would there be a right-shift to begin with?
> (maybe add check-output-excludes: %arg1)
I'm not sure. It may be an error in the testcase, maybe a copy-paste
from some other tests, but I think it comes from some simplification
steps involving masks and shift and where a masking operation like
(x & 0xfff00000) is first virtually transformed into ((x >> 20) << 20)
before being simplified away.
Yes, checking the absence of %arg1 is a good idea.
> > + */
> > diff --git a/validation/optim/lsr-or-and0.c b/validation/optim/lsr-or-and0.c
> > new file mode 100644
> > index 000000000000..3c369cb9497e
> > --- /dev/null
> > +++ b/validation/optim/lsr-or-and0.c
> > @@ -0,0 +1,23 @@
> > +#define S 12
> > +
> > +// ((x & M) | b) >> S;
> > +// -> ((x >> S) & (M >> S)) | (b >> S)
>
> OK
>
> > +// 0a: (M >> S) == 0
> > +// 0b: (x >> S) == 0
> > +// 0c: (b >> S) == 0
>
> I do not understand what these three lines are trying to say! :(
It's just some leftover of personal notes about the 3 opportunities
of simplifications. It's probably best to remove.
> > +
> > +int lsr_or_and0a(unsigned int x, unsigned int b)
>
> s/and0a/and0/ - was there an '_and0b' at one time?
Yes, most probably.
> > diff --git a/validation/optim/shl-or-constant2.c b/validation/optim/shl-or-constant2.c
> > new file mode 100644
> > index 000000000000..9dbde3b574d7
> > --- /dev/null
> > +++ b/validation/optim/shl-or-constant2.c
> > @@ -0,0 +1,12 @@
> > +unsigned shl_or_constant1(unsigned a)
>
> s/_constant1/_constant2/
Yes, it's better so.
Thanks,
-- Luc
next prev parent reply other threads:[~2020-09-06 18:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-06 12:40 [PATCH 0/3] fix & extend mask related testcases Luc Van Oostenryck
2020-09-06 12:40 ` [PATCH 1/3] add more testcases for existing AND/OR simplifications Luc Van Oostenryck
2020-09-06 16:12 ` Ramsay Jones
2020-09-06 18:52 ` Luc Van Oostenryck [this message]
2020-09-06 12:40 ` [PATCH 2/3] add more testcases for AND/OR simplification Luc Van Oostenryck
2020-09-06 16:38 ` Ramsay Jones
2020-09-06 16:46 ` Ramsay Jones
2020-09-06 19:10 ` Luc Van Oostenryck
2020-09-06 20:12 ` Ramsay Jones
2020-09-06 21:15 ` Luc Van Oostenryck
2020-09-06 12:40 ` [PATCH 3/3] optim: fix some testcases related to bitfield manipulation Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200906185226.sjfbnuo7dbrfc3dm@ltop.local \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=ramsay@ramsayjones.plus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox