[PATCH] D64521: [InstCombine] Dropping redundant masking before left-shift [4/5] (PR42563)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 11:22:21 PDT 2019
lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, nikic, huihuiz, xbolva00.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.
lebedev.ri added a parent revision: D64519: [InstCombine] Dropping redundant masking before left-shift [3/5] (PR42563).
If we have some pattern that leaves only some low bits set, and then performs
left-shift of those bits, if none of the bits that are left after the final
shift are modified by the mask, we can omit the mask.
There are many variants to this pattern:
e. `((x << MaskShAmt) l>> MaskShAmt) << ShiftShAmt`
All these patterns can be simplified to just:
`x << ShiftShAmt`
iff:
e. `(ShiftShAmt-MaskShAmt) s>= 0` (i.e. `ShiftShAmt u>= MaskShAmt`)
alive proofs:
e: https://rise4fun.com/Alive/0FT
For now let's start with patterns where both shift amounts are variable,
with trivial constant "offset" between them, since i believe this is
both simplest to handle and i think this is most common.
But again, there are likely other variants where we could use
ValueTracking/ConstantRange to handle more cases.
https://bugs.llvm.org/show_bug.cgi?id=42563
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64521
Files:
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-variant-e.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64521.209028.patch
Type: text/x-patch
Size: 5145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190710/71aaf908/attachment.bin>
More information about the llvm-commits
mailing list