← Back to Pull requests

[AArch64] Combine SVE AND and XOR to BIC for _m form #238784

Open
pvimal816a opened this pull request with 210 lines diff across 3 files
View on GitHub
pvimal816a pvimal816a commented on Nov 04, 2026 13:37 UTC
Author

Add patterns to combine the expressions of the following type to BIC when possible:

return svand_u32_m(svptrue_b32(), a, sveor_u32_x(svptrue_b32(), a, b));

Cover symmetric case where result of AND is used by EOR for the above expression.

Cover cases where the inner node is of _u form like sveor_u32_u or sveand_u32_u.

Cover cases where the inner node is of _m/_z form under matching predicates or all-active predicates for the inner node.

Also, cover the case where the inner node is a normal LLVM AND(or XOR) node.

Lower the case where both the predicates are all-active to unpredicated BIC.

Diff: 210 lines (+165 / -45) across 3 files Reviewer: CarolineConcatto Review duration: 38583m
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.38) × (1 − Review Confidence (0.92)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.38 · 210 lines diff across 3 files
0.38
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.92 · 3 substantive comment(s)
0.92
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
91%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.320
Real PR Conversation Timeline
4 items
llvmorg-github-actions[bot] llvmorg-github-actions[bot] commented on Nov 04, 2026 13:38 UTC
Bot

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-aarch64

Author: Vimal Patel (pvimal816a)

<details>
<summary>Changes</summary>

Add patterns to combine the expressions of the following type to BIC when possible:

return svand_u32_m(svptrue_b32(), a, sveor_u32_x(svptrue_b32(), a, b));

Cover symmetric case where result of AND is used by EOR for the above expression.

Cover cases where the inner node is of _u form like sveor_u32_u or sveand_u32_u.

Cover cases where the inner node is of _m/_z form under matching predicates or all-active predicates for the inner node.

Also, cover the case where the inner node is a normal LLVM AND(or XOR) node.

Lower the case where both the predicates are all-active to unpredicated BIC.

---
Full diff: https://github.com/llvm/llvm-project/pull/238784.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td (+82)

  • (modified) llvm/test/CodeGen/AArch64/sve-intrinsics-and-xor.ll (+116)

  • (modified) llvm/test/CodeGen/AArch64/sve-intrinsics-xor-and.ll (+116)
  • ``````

    diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
    index f097d88be226e..142e12f83af45 100644
    --- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
    +++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
    @@ -918,6 +918,88 @@ let Predicates = [HasSVE_or_SME] in {
       defm : SVEMergingAndNotPats<nxv8i16, nxv8i1, BIC_ZPmZ_H>;
       defm : SVEMergingAndNotPats<nxv4i32, nxv4i1, BIC_ZPmZ_S>;
       defm : SVEMergingAndNotPats<nxv2i64, nxv2i1, BIC_ZPmZ_D>;
    +
    +  multiclass SVEMergingAndXorPats<ValueType VT, ValueType PT, Instruction PredBic> {
    +    // Inactive lanes in EOR may be replaced by a & ~b in the result.
    +    def : Pat<(VT (int_aarch64_sve_and PT:$pg, VT:$a,
    +                    (VT (SVEEorU (PT srcvalue), VT:$a, VT:$b)))),
    +              (PredBic $pg, $a, $b)>;
    +
    +    // Matching predicate ensures that active lanes in AND can be replaced by a & ~b.
    +    def : Pat<(VT (int_aarch64_sve_and PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_eor PT:$pg, VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // Similar to above, matching predicate ensures that inactive lanes in EOR are don't
    +    // care for final result. Rests are equivalent to a & ~b.
    +    def : Pat<(VT (int_aarch64_sve_and PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_eor_z PT:$pg, VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // All active lanes in EOR ensures that all active lanes in AND are equivalent to a & ~b.
    +    def : Pat<(VT (int_aarch64_sve_and PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_eor (PT (SVEAllActive)), VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // Similar to the preceding pattern but for _z form of EOR.
    +    def : Pat<(VT (int_aarch64_sve_and PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_eor_z (PT (SVEAllActive)), VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // Normal LLVM XOR.
    +    def : Pat<(VT (int_aarch64_sve_and PT:$pg, VT:$a, (xor VT:$a, VT:$b))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // There is no active lane in AND. So, unpredicated BIC could be used.
    +    def : Pat<(VT (int_aarch64_sve_and (PT (SVEAllActive)), VT:$a,
    +                    (VT (int_aarch64_sve_eor_z (PT (SVEAllActive)), VT:$a, VT:$b)))),
    +          (BIC_ZZZ $a, $b)>;
    +  }
    +  defm : SVEMergingAndXorPats<nxv16i8, nxv16i1, BIC_ZPmZ_B>;
    +  defm : SVEMergingAndXorPats<nxv8i16, nxv8i1, BIC_ZPmZ_H>;
    +  defm : SVEMergingAndXorPats<nxv4i32, nxv4i1, BIC_ZPmZ_S>;
    +  defm : SVEMergingAndXorPats<nxv2i64, nxv2i1, BIC_ZPmZ_D>;
    +
    +  multiclass SVEMergingXorAndPats<ValueType VT, ValueType PT, Instruction PredBic> {
    +    // Inactive lanes in AND may be replaced by a & b in the result.
    +    def : Pat<(VT (int_aarch64_sve_eor PT:$pg, VT:$a,
    +                    (VT (SVEAndU (PT srcvalue), VT:$a, VT:$b)))),
    +              (PredBic $pg, $a, $b)>;
    +
    +    // Matching predicate ensures that active lanes in EOR can be replaced by a & ~b.
    +    def : Pat<(VT (int_aarch64_sve_eor PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_and PT:$pg, VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // Similar to above, matching predicate ensures that inactive lanes in AND are don't
    +    // care for final result. Rests are equivalent to a & ~b.
    +    def : Pat<(VT (int_aarch64_sve_eor PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_and_z PT:$pg, VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // All active lanes in AND ensures that all active lanes in EOR are equivalent to a & ~b.
    +    def : Pat<(VT (int_aarch64_sve_eor PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_and (PT (SVEAllActive)), VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // Similarly, for _z form of AND.
    +    def : Pat<(VT (int_aarch64_sve_eor PT:$pg, VT:$a,
    +                    (VT (int_aarch64_sve_and_z (PT (SVEAllActive)), VT:$a, VT:$b)))),
    +          (PredBic $pg, $a, $b)>;
    +
    +    // Normal LLVM AND.
    +    def : Pat<(VT (int_aarch64_sve_eor PT:$pg, VT:$a, (and VT:$a, VT:$b))),
    +              (PredBic $pg, $a, $b)>;
    +
    +    // With both predicates all-active, no inactive lanes need preserving.
    +    def : Pat<(VT (int_aarch64_sve_eor (PT (SVEAllActive)), VT:$a,
    +                    (VT (int_aarch64_sve_and_z (PT (SVEAllActive)), VT:$a, VT:$b)))),
    +          (BIC_ZZZ $a, $b)>;
    +  }
    +  defm : SVEMergingXorAndPats<nxv16i8, nxv16i1, BIC_ZPmZ_B>;
    +  defm : SVEMergingXorAndPats<nxv8i16, nxv8i1, BIC_ZPmZ_H>;
    +  defm : SVEMergingXorAndPats<nxv4i32, nxv4i1, BIC_ZPmZ_S>;
    +  defm : SVEMergingXorAndPats<nxv2i64, nxv2i1, BIC_ZPmZ_D>;
     } // End HasSVE_or_SME
     
     let Predicates = [HasSVE_or_SME, UseExperimentalZeroingPseudos] in {
    diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-and-xor.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-and-xor.ll
    index f7b9934bad87e..0b2c1e9f312e4 100644
    --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-and-xor.ll
    +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-and-xor.ll
    @@ -97,6 +97,88 @@ define <vscale x 4 x i32> @and_u_eor_z_all_active(<vscale x 4 x i1> %pg, <vscale
       ret <vscale x 4 x i32> %and
     }
     
    +define <vscale x 4 x i32> @and_m_eor_u(<vscale x 4 x i1> %pg1, <vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_eor_u:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p1/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.u.nxv4i32(<vscale x 4 x i1> %pg1, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %eor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
    +define <vscale x 4 x i32> @and_m_xor(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_xor:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %xor = xor <vscale x 4 x i32> %a, %b
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %xor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
    +define <vscale x 4 x i32> @and_m_eor_m(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_eor_m:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %eor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
    +define <vscale x 4 x i32> @and_m_eor_m_pred_mismatch(<vscale x 4 x i1> %pg1, <vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_eor_m_pred_mismatch:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    mov z2.d, z0.d
    +; CHECK-NEXT:    eor z2.s, p0/m, z2.s, z1.s
    +; CHECK-NEXT:    and z0.s, p1/m, z0.s, z2.s
    +; CHECK-NEXT:    ret
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg1, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %eor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
    +define <vscale x 4 x i32> @and_m_eor_z(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_eor_z:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.z.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %eor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
    +define <vscale x 4 x i32> @and_m_eor_m_all_active(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_eor_m_all_active:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %eor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
    +define <vscale x 4 x i32> @and_m_eor_z_all_active(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_eor_z_all_active:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.z.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %eor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
    +define <vscale x 4 x i32> @and_m_all_active_eor_z_all_active(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: and_m_all_active_eor_z_all_active:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.d, z0.d, z1.d
    +; CHECK-NEXT:    ret
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.z.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %eor)
    +  ret <vscale x 4 x i32> %and
    +}
    +
     define <vscale x 16 x i8> @and_u_xor_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
     ; CHECK-LABEL: and_u_xor_i8:
     ; CHECK:       // %bb.0:
    @@ -107,8 +189,42 @@ define <vscale x 16 x i8> @and_u_xor_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i
       ret <vscale x 16 x i8> %and
     }
     
    +define <vscale x 16 x i8> @and_m_xor_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
    +; CHECK-LABEL: and_m_xor_i8:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.b, p0/m, z0.b, z1.b
    +; CHECK-NEXT:    ret
    +  %xor = xor <vscale x 16 x i8> %a, %b
    +  %and = tail call <vscale x 16 x i8> @llvm.aarch64.sve.and.nxv16i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %xor)
    +  ret <vscale x 16 x i8> %and
    +}
    +
    +define <vscale x 8 x i16> @and_m_xor_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
    +; CHECK-LABEL: and_m_xor_i16:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.h, p0/m, z0.h, z1.h
    +; CHECK-NEXT:    ret
    +  %xor = xor <vscale x 8 x i16> %a, %b
    +  %and = tail call <vscale x 8 x i16> @llvm.aarch64.sve.and.nxv8i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %xor)
    +  ret <vscale x 8 x i16> %and
    +}
    +
    +define <vscale x 2 x i64> @and_m_xor_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
    +; CHECK-LABEL: and_m_xor_i64:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.d, p0/m, z0.d, z1.d
    +; CHECK-NEXT:    ret
    +  %xor = xor <vscale x 2 x i64> %a, %b
    +  %and = tail call <vscale x 2 x i64> @llvm.aarch64.sve.and.nxv2i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %xor)
    +  ret <vscale x 2 x i64> %and
    +}
    +
    +declare <vscale x 16 x i8> @llvm.aarch64.sve.and.nxv16i8(<vscale x 16 x i1>, <vscale x 16 x i8>, <vscale x 16 x i8>)
     declare <vscale x 16 x i8> @llvm.aarch64.sve.and.u.nxv16i8(<vscale x 16 x i1>, <vscale x 16 x i8>, <vscale x 16 x i8>)
    +declare <vscale x 8 x i16> @llvm.aarch64.sve.and.nxv8i16(<vscale x 8 x i1>, <vscale x 8 x i16>, <vscale x 8 x i16>)
    +declare <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.and.u.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
    +declare <vscale x 2 x i64> @llvm.aarch64.sve.and.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, <vscale x 2 x i64>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.eor.u.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.eor.z.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
    diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-xor-and.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-xor-and.ll
    index fff20818d9b0d..d742fcc50ab34 100644
    --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-xor-and.ll
    +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-xor-and.ll
    @@ -97,6 +97,88 @@ define <vscale x 4 x i32> @eor_u_and_z_all_active(<vscale x 4 x i1> %pg, <vscale
       ret <vscale x 4 x i32> %eor
     }
     
    +define <vscale x 4 x i32> @eor_m_and_u(<vscale x 4 x i1> %pg1, <vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_and_u:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p1/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.u.nxv4i32(<vscale x 4 x i1> %pg1, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
    +define <vscale x 4 x i32> @eor_m_and(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_and:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %and = and <vscale x 4 x i32> %a, %b
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
    +define <vscale x 4 x i32> @eor_m_and_m(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_and_m:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
    +define <vscale x 4 x i32> @eor_m_and_m_pred_mismatch(<vscale x 4 x i1> %pg1, <vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_and_m_pred_mismatch:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    mov z2.d, z0.d
    +; CHECK-NEXT:    and z2.s, p0/m, z2.s, z1.s
    +; CHECK-NEXT:    eor z0.s, p1/m, z0.s, z2.s
    +; CHECK-NEXT:    ret
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> %pg1, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg2, <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
    +define <vscale x 4 x i32> @eor_m_and_z(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_and_z:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.z.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
    +define <vscale x 4 x i32> @eor_m_and_m_all_active(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_and_m_all_active:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
    +define <vscale x 4 x i32> @eor_m_and_z_all_active(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_and_z_all_active:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.s, p0/m, z0.s, z1.s
    +; CHECK-NEXT:    ret
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.z.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
    +define <vscale x 4 x i32> @eor_m_all_active_and_z_all_active(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    +; CHECK-LABEL: eor_m_all_active_and_z_all_active:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.d, z0.d, z1.d
    +; CHECK-NEXT:    ret
    +  %and = tail call <vscale x 4 x i32> @llvm.aarch64.sve.and.z.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
    +  %eor = tail call <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1> splat (i1 true), <vscale x 4 x i32> %a, <vscale x 4 x i32> %and)
    +  ret <vscale x 4 x i32> %eor
    +}
    +
     define <vscale x 16 x i8> @eor_u_and_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
     ; CHECK-LABEL: eor_u_and_i8:
     ; CHECK:       // %bb.0:
    @@ -107,11 +189,45 @@ define <vscale x 16 x i8> @eor_u_and_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i
       ret <vscale x 16 x i8> %eor
     }
     
    +define <vscale x 16 x i8> @eor_m_and_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
    +; CHECK-LABEL: eor_m_and_i8:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.b, p0/m, z0.b, z1.b
    +; CHECK-NEXT:    ret
    +  %and = and <vscale x 16 x i8> %a, %b
    +  %eor = tail call <vscale x 16 x i8> @llvm.aarch64.sve.eor.nxv16i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %and)
    +  ret <vscale x 16 x i8> %eor
    +}
    +
    +define <vscale x 8 x i16> @eor_m_and_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
    +; CHECK-LABEL: eor_m_and_i16:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.h, p0/m, z0.h, z1.h
    +; CHECK-NEXT:    ret
    +  %and = and <vscale x 8 x i16> %a, %b
    +  %eor = tail call <vscale x 8 x i16> @llvm.aarch64.sve.eor.nxv8i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %and)
    +  ret <vscale x 8 x i16> %eor
    +}
    +
    +define <vscale x 2 x i64> @eor_m_and_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
    +; CHECK-LABEL: eor_m_and_i64:
    +; CHECK:       // %bb.0:
    +; CHECK-NEXT:    bic z0.d, p0/m, z0.d, z1.d
    +; CHECK-NEXT:    ret
    +  %and = and <vscale x 2 x i64> %a, %b
    +  %eor = tail call <vscale x 2 x i64> @llvm.aarch64.sve.eor.nxv2i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %and)
    +  ret <vscale x 2 x i64> %eor
    +}
    +
     declare <vscale x 16 x i8> @llvm.aarch64.sve.eor.u.nxv16i8(<vscale x 16 x i1>, <vscale x 16 x i8>, <vscale x 16 x i8>)
    +declare <vscale x 16 x i8> @llvm.aarch64.sve.eor.nxv16i8(<vscale x 16 x i1>, <vscale x 16 x i8>, <vscale x 16 x i8>)
    +declare <vscale x 8 x i16> @llvm.aarch64.sve.eor.nxv8i16(<vscale x 8 x i1>, <vscale x 8 x i16>, <vscale x 8 x i16>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.and.u.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.eor.u.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
    +declare <vscale x 4 x i32> @llvm.aarch64.sve.eor.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.and.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
     declare <vscale x 4 x i32> @llvm.aarch64.sve.and.z.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>)
    +declare <vscale x 2 x i64> @llvm.aarch64.sve.eor.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>, <vscale x 2 x i64>)
     ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
     ; SME: {{.*}}
     ; SVE: {{.*}}
    
    
    ``````

    </details>

    CarolineConcatto CarolineConcatto commented on code on Nov 05, 2026 15:27 UTC
    Code Review
    llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td:1
    @@ -921,6 +921,88 @@ let Predicates = [HasSVE_or_SME] in {
       defm : SVEMergingAndNotPats<nxv8i16, nxv8i1, BIC_ZPmZ_H>;
       defm : SVEMergingAndNotPats<nxv4i32, nxv4i1, BIC_ZPmZ_S>;
       defm : SVEMergingAndNotPats<nxv2i64, nxv2i1, BIC_ZPmZ_D>;
    +
    +  multiclass SVEMergingAndXorPats<ValueType VT, ValueType PT, Instruction PredBic> {

    Have you consider adding this to the multiclass where BIC_ZPmZ is defined

    pvimal816a pvimal816a commented on code on Nov 06, 2026 08:38 UTC
    Code Review
    llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td:1
    @@ -921,6 +921,88 @@ let Predicates = [HasSVE_or_SME] in {
       defm : SVEMergingAndNotPats<nxv8i16, nxv8i1, BIC_ZPmZ_H>;
       defm : SVEMergingAndNotPats<nxv4i32, nxv4i1, BIC_ZPmZ_S>;
       defm : SVEMergingAndNotPats<nxv2i64, nxv2i1, BIC_ZPmZ_D>;
    +
    +  multiclass SVEMergingAndXorPats<ValueType VT, ValueType PT, Instruction PredBic> {

    Looks like I missed it. Let me check.

    Assignees
    pvimal816a pvimal816a
    Labels
    risk: low confidence: 91.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.9% (MEDIUM) · Higher = larger blast radius
    37.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 91.8% · Lower = rushed or shallow review
    91.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.1% · Safe to merge
    3.1%