[llvm-dev] [IR canonicalization] 6 ways to choose {-1,0,1}
Alexandre Isoard via llvm-dev
llvm-dev at lists.llvm.org
Tue Jul 11 15:21:25 PDT 2017
On Tue, Jul 11, 2017 at 10:08 PM, David Majnemer via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> IMO, canonicalization is driven by a few priorities:
> - How easy is it for the rest of the optimizer to reason about the IR
> - How easy is it to lower the IR to "The Right Thing (TM)"
>
> I think it is hard to know which is best without resorting to a
> case-by-case analysis, mostly because of stuff like ComputeKnownBits.
>
> Outside a few special cases, ComputeKnownBits isn't very smart when it
> comes to select: it just takes the intersection of the two possibilities.
> This can lose quite a bit of information.
>
> I'd feel a lot better about always canonicalizing to select if the
> backends are strengthened to lower those selects to something good (without
> relying on CMOV, etc.) and if ComputeKnownBits dealt with select better.
>
I don't see how ComputeKnownBits can be improved here. Because the return
value can be 0 or -1 then any bit can be 0 or 1, which is without
information, but optimal.
This is a fundamental limitation of the ComputeKnownBits representation.
Note we could drastically improve it by having two set of ComputeKnownBits:
- one for when the MSB is 0
- one for when the MSB is 1
But that is an other discussion I guess.
--
*Alexandre Isoard*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170711/c3d6e008/attachment.html>
More information about the llvm-dev
mailing list