[llvm] [AArch64][SVE] Optimize svand_z/svorr_z with all-true predicates. (PR #160408)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 05:51:25 PDT 2025


================
@@ -1623,6 +1643,22 @@ simplifySVEIntrinsicBinOp(InstCombiner &IC, IntrinsicInst &II,
     return ⅈ
   }
 
+  // For logical operations with all-true predicates, apply simplifications.
+  if (isAllActivePredicate(Pg)) {
+    if (Opc == Instruction::And) {
+      if (isAllActivePredicate(Op1))
+        return IC.replaceInstUsesWith(II, Op2);
+      if (isAllActivePredicate(Op2))
+        return IC.replaceInstUsesWith(II, Op1);
+    }
+    if (Opc == Instruction::Or) {
+      if (isAllActivePredicate(Op1))
+        return IC.replaceInstUsesWith(II, Op1);
+      if (isAllActivePredicate(Op2))
+        return IC.replaceInstUsesWith(II, Op2);
+    }
+  }
----------------
paulwalker-arm wrote:

Having opcode specific handling within `simplifySVEIntrinsicBinOp` kind of defeats the point.  The goal is to use the result of `simplifyBinOp`, which should already handle things like `A & true => A`.

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


More information about the llvm-commits mailing list