[llvm] [AArch64] Match BSP through trunc(and) canonicalization in OR combine (PR #198277)

Rajveer Singh Bharadwaj via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 06:13:19 PDT 2026


================

----------------
Rajveer100 wrote:

```suggestion
  // Match the trunc-hoisted shape that hides BSP from the cases below:
  //   (or (trunc (and A B)) (and C (xor (trunc A) -1)))
  //     => BSP(trunc A, trunc B, C)
  // The xor constant uses
  // m_ConstInt + isAllOnes() rather than m_AllOnes because m_AllOnes rejects
  // post-legalize splats whose element storage is wider than the lane.
```

The reason why commutative approach worked is because of canonicalization of IR by moving complex expression to the left so I think we just got lucky here.

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


More information about the llvm-commits mailing list