[llvm] [LV] Add cost for VPInstruction::Not. (PR #198445)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Sun May 24 18:28:19 PDT 2026


================
@@ -1285,6 +1285,17 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
     return Ctx.TTI.getIndexedVectorInstrCostFromEnd(Instruction::ExtractElement,
                                                     VecTy, Ctx.CostKind, 0);
   }
+  case VPInstruction::Not: {
+    Type *ValTy = Ctx.Types.inferScalarType(this);
+    // InstCombine will fold `xor` to the conditional branch.
+    if (auto *U = const_cast<VPUser *>(getSingleUser()))
+      if (match(U, m_BranchOnCond(m_VPValue())))
+        return 0;
+    if (!vputils::onlyFirstLaneUsed(this))
+      ValTy = toVectorTy(ValTy, VF);
----------------
ElvisWang123 wrote:

Added test `AArch64/vpinstruction-not-cost.ll`. And show the test changes in [375b00f](https://github.com/llvm/llvm-project/pull/198445/commits/375b00f74efd99c425c82733a2f3dbaf45106e74). Thanks!

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


More information about the llvm-commits mailing list