From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH] warn when zero-extending a negation
Date: Thu, 17 Dec 2020 01:35:57 +0100 [thread overview]
Message-ID: <20201217003557.qpcawxx46cwmvz27@ltop.local> (raw)
In-Reply-To: <20201216235152.6oinwuti3uzvwai5@ltop.local>
On Thu, Dec 17, 2020 at 12:51:52AM +0100, Luc Van Oostenryck wrote:
>
> But replacing a trunc + zext by the corresponding masking, very
> little, if anything is done for such 'mixed-width' expressions.
> So, I'm even a bit surprised by the not.8 but well ...
This bothered me a bit and kept me awake, so I had to check.
I think that the situation is caused by some premature optimization
for the ~ operator in expression.c:cast_to(). It saves the allocation
and initialization of one expression but makes things more complicated
at linearization and simplification. If this is disabled, then the IR
simplification returns what I was expecting:
maskout:
zext.32 %r2 <- (8) %arg1
shl.32 %r5 <- $1, %arg2
not.32 %r6 <- %r5
and.32 %r9 <- %r6, $255
and.32 %r10 <- %r2, %r9
trunc.8 %r11 <- (32) %r10
ret.8 %r11
and some reassociation patches (coming soon) will simplify away
the masking with $255 and the trunc.8
-- Luc
prev parent reply other threads:[~2020-12-17 0:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1607964894252100@kroah.com>
[not found] ` <4562FE1C-9B03-4EE4-972A-688B61014466@fb.com>
[not found] ` <ACDB8DAF-9585-4C35-956B-75A23BE9C7A8@fb.com>
2020-12-16 2:11 ` Patch "[PATCH 1/2] Revert "md: change mddev 'chunk_sectors' from int to" has been added to the 5.10-stable tree Linus Torvalds
2020-12-16 22:24 ` [PATCH] warn when zero-extending a negation Luc Van Oostenryck
2020-12-16 22:37 ` Linus Torvalds
2020-12-16 23:51 ` Luc Van Oostenryck
2020-12-17 0:35 ` Luc Van Oostenryck [this message]
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=20201217003557.qpcawxx46cwmvz27@ltop.local \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).