[llvm] [AArch64][SVE2] Allow commuting two-input NBSL/BSL2N idioms. (PR #184847)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 12 06:49:49 PDT 2026


================
@@ -4147,6 +4147,20 @@ let Predicates = [HasSVE2_or_SME] in {
   defm BSL2N_ZZZZ : sve2_int_bitwise_ternary_op<0b101, "bsl2n", AArch64bsl2n>;
   defm NBSL_ZZZZ  : sve2_int_bitwise_ternary_op<0b111, "nbsl",  AArch64nbsl>;
 
+  // Pseudos for commutable operations that expand to NBSL or BSL2N. These can
+  // avoid a COPY if one of the source registers can be clobbered, or otherwise
+  // use a MOVPRFX.
+  let isCommutable = 1, hasSideEffects = 0 in {
+    // EON (a, b) = BSL2N (a, a, b) = BSL2N (b, b, a)
+    def EON_ZZZ : Pseudo<(outs ZPR64:$Zd), (ins ZPR64:$Zn, ZPR64:$Zm), []>;
----------------
paulwalker-arm wrote:

Thanks.  Just confirmed for myself and I think I made the same incorrect observation during the original BSLN work :( I shall try harder to remember this time.  Anyways, I retract this comment.

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


More information about the llvm-commits mailing list