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

Xaver Fabian via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 05:17:57 PDT 2026


XFabian wrote:



This handles known and partially-known masks nicely, but I don't think it folds the case from the issue title #204945— pext(x & m, m) where m is a variable:

```llvm
define i32 @test_pext_and_same_variable_mask(i32 %x, i32 %m) {
   %and = and i32 %x, %m
   %r = tail call i32 @llvm.pext.i32(i32 %and, i32 %m)
  ret i32 %r
 }
```
 Would it make sense to keep the `m_c_And(m_Value(X), m_Specific(...))` fold from #204954 in `visitCallInst` alongside this? The two seem complementary rather than alternatives. Note `test_pext_and_unknown_mask_32` uses `and %x, 63` with mask `%m`, so it doesn't cover this.

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


More information about the llvm-commits mailing list