[llvm-branch-commits] [llvm] [AArch64] Add patterns to combine SVE AND and XOR to BIC (PR #238442)

Vimal Patel via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 6 02:15:35 PST 2026


================
@@ -560,10 +561,17 @@ def AArch64bic : PatFrags<(ops node:$op1, node:$op2),
                            (and node:$op1, (xor node:$op2, (SVEAllActive))),
                            (AArch64bic_node node:$op1, node:$op2)]>;
 
-// Match AND_U with either data operand order, keeping the predicate unchanged.
-def SVEAndU : PatFrags<(ops node:$pg, node:$a, node:$b),
-                      [(AArch64and_u node:$pg, node:$a, node:$b),
-                       (AArch64and_u node:$pg, node:$b, node:$a)]>;
+// Match `intr` with either data operand order, keeping the predicate unchanged.
+class CommPredBinPatFrags<SDPatternOperator intr>
+  : PatFrags<(ops node:$pg, node:$a, node:$b),
+            [(intr node:$pg, node:$a, node:$b),
+             (intr node:$pg, node:$b, node:$a)]>;
+def SVEAndU : CommPredBinPatFrags<AArch64and_u>;
+def SVEAndM : CommPredBinPatFrags<int_aarch64_sve_and>;
+def SVEAndZ : CommPredBinPatFrags<int_aarch64_sve_and_z>;
----------------
pvimal816a wrote:

Actually, the third pattern that is part of AArch64and_z seems incompatible with what we need in the rewrite we are introducing here:
```
def AArch64and_z  : PatFrags<(ops node:$pg, node:$op1, node:$op2),
                             [(int_aarch64_sve_and_z node:$pg, node:$op1, node:$op2),
                              (int_aarch64_sve_and_z node:$pg, node:$op2, node:$op1),
                              (and node:$pg, (and node:$op1, node:$op2))]>;     // <---------------- This one.
```
It expects `$pg` to have the same type as `$op1` and `$op2`.

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


More information about the llvm-branch-commits mailing list