3 Commits

Author SHA1 Message Date
Noah Goldstein
4fcfff4f2d Use analyzeKnownBitsFromAndXorOr in SimplifyDemandedUseBits for and/xor/or
There are extra patterns that have for these three logic operations
that aren't covered in `SimplifyDemandedUseBits`. To avoid duplicating
the code, just use `analyzeKnownBitsFromAndXorOr` in
`SimplifyDemandedUseBits` to get full coverage.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D142429
2023-02-23 19:52:17 -06:00
Noah Goldstein
9a8f517f57 [ValueTracking] Add KnownBits patterns xor(x, x - 1) and and(x, -x) for knowing upper bits to be zero
These two BMI pattern will clear the upper bits of result past the
first set bit. So if we know a single bit in `x` is set, we know that
`results[bitwidth - 1, log2(x) + 1] = 0`.

Alive2:
blsmsk: https://alive2.llvm.org/ce/z/a397BS
blsi: https://alive2.llvm.org/ce/z/tsbQhC

Differential Revision: https://reviews.llvm.org/D142271
2023-02-18 13:31:17 -06:00
Noah Goldstein
c8fb2775ce [ValueTracking] Add tests for known bits after common BMI pattern (blsmsk/blsi); NFC
Differential Revision: https://reviews.llvm.org/D142270
2023-02-18 13:31:12 -06:00