[llvm] [InstCombine] Add demanded-bits pext handling (PR #205092)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 02:25:41 PDT 2026


mygitljf wrote:

Thanks @eisenwave . The previous implementation used the result demanded mask to derive demanded bits for the LHS, but still treated every RHS bit as demanded, so the two mask cases you described were not handled.

I updated it to demand the mask prefix through the Nth known-one bit, where `N = DemandedMask.getActiveBits()`. Unknown bits inside the prefix remain demanded and do not count toward the cutoff; if there are fewer than N known-one bits, the implementation conservatively demands the full mask. This also handles sparse demanded-result masks, such as demanding only result bit 3.

I added coverage for the low-four-ranks case, `pext(x, y) & 1` with mask bit 0 known set, the sparse-demand case, the insufficient-known-ones fallback, and the corresponding i64 and vector paths. 

https://github.com/llvm/llvm-project/pull/205092


More information about the llvm-commits mailing list