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

Mariusz Masztalerczuk via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 00:02:21 PDT 2026


mmasztalerczuk wrote:

> Please add tests for all commutative scenarios, like flipped `and` operands (ex. and bi ai) and other combinations to ensure this works in all cases.

Extended the matching to commutative operand orders (really just m_Xor in the end). Managed to do it without the custom matcher, m_ConstInt was enough.

Added cases that flip the operands around. For AND/OR they actually test the commutativity. The xor one passes, but it doesn't really test xor commutativity, since the code canonicalizes the constant to the right, so the matcher never sees it on the left. Keeping it anyway as a regression test to make sure the fold still fires for that IR shape.

Honestly these changes are mostly a refactor (less code), since the new tests also pass on the previous version. Let me know which version you prefer :)

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


More information about the llvm-commits mailing list