[PATCH] D63829: [InstCombine] Shift amount reassociation in bittest (PR42399)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 10:58:06 PDT 2019
lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, nikic, RKSimon.
lebedev.ri added a project: LLVM.
Given pattern:
`icmp eq/ne (and ((x shift Q), (y oppositeshift K))), 0`
we should move shifts to the same hand of 'and', i.e. rewrite as
`icmp eq/ne (and (x shift (Q+K)), y), 0` iff `(Q+K) u< bitwidth(x)`
It might be tempting to not restrict this to situations where we know
we'd fold two shifts together, but i'm not sure what rules should there be
to avoid endless combine loops.
We pick the same shift that was originally used to shift the variable we picked to shift:
https://rise4fun.com/Alive/6x1v
Should fix PR42399 <https://bugs.llvm.org/show_bug.cgi?id=42399>.
Repository:
rL LLVM
https://reviews.llvm.org/D63829
Files:
lib/Transforms/InstCombine/InstCombineCompares.cpp
test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63829.206709.patch
Type: text/x-patch
Size: 15617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190626/8ffd13e8/attachment.bin>
More information about the llvm-commits
mailing list