[PATCH] D116483: [InstCombine] fold opposite shifts around an add
Erik Desjardins via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 1 14:11:40 PST 2022
erikdesjardins created this revision.
Herald added a subscriber: hiraditya.
erikdesjardins requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
((X << C) + Y) >>u C --> (X + (Y >>u C)) & (-1 >>u C)
https://alive2.llvm.org/ce/z/DY9DPg
This replaces a shift with an 'and', and in the case
where the add has a constant operand, it eliminates
both shifts.
As noted in the TODO comment, we already have this fold when
the shifts are in the opposite order (and that code handles
bitwise logic ops too).
Fixes #52851
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116483
Files:
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/lshr.ll
llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116483.396880.patch
Type: text/x-patch
Size: 52168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220101/4dbb42b8/attachment-0001.bin>
More information about the llvm-commits
mailing list