[llvm] [AArch64][SVE2p1] Remove redundant PTESTs when predicate is a WHILEcc_x2 (PR #156478)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 05:14:30 PDT 2025


================
@@ -1487,6 +1487,21 @@ AArch64InstrInfo::canRemovePTestInstr(MachineInstr *PTest, MachineInstr *Mask,
   bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
   bool PredIsWhileLike = isWhileOpcode(PredOpcode);
 
+  uint64_t PredEltSize = 0;
+  if (PredIsWhileLike)
+    PredEltSize = getElementSizeForOpcode(PredOpcode);
+
+  if (Pred->isCopy()) {
+    // Instructions which return a multi-vector (e.g. WHILECC_x2) require copies
+    // before the branch to extract each subregister.
+    auto Op = Pred->getOperand(1);
+    if (Op.isReg() && Op.getReg().isVirtual() && Op.getSubReg() != 0) {
----------------
paulwalker-arm wrote:

Is "Op.getSubReg() != 0" sufficient? Should it be exactly `AArch64::psub0`?

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


More information about the llvm-commits mailing list