[PATCH] D142271: [ValueTracking] Add KnownBits patterns `xor(x, x - 1)` and `and(x, -x)` for knowing upper bits to be zero
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 29 04:08:36 PST 2023
foad added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1087
+ if (match(I, m_c_BinOp(m_Value(X), m_Neg(m_Deferred(X))))) {
+ // -(-x) == x so pick whichever we can get a better result with.
+ if (Known.countMaxTrailingZeros() <= Known2.countMaxTrailingZeros())
----------------
A less "if"fy way to implement this would be:
```
Known = Known.blsi();
Known2 = Known2.blsi();
// should probably have a helper for the following two lines, similar to KnownBits::commonBits
Known.Zero |= Known2.Zero;
Known.One |= Known2.One;
```
(But I'm still sceptical that it gives any practical benefit.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142271/new/
https://reviews.llvm.org/D142271
More information about the llvm-commits
mailing list