[llvm] [VPlan] Compute scalar cost based on VPlan0 instead of legacy CM. (PR #196845)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 07:35:01 PDT 2026


================
@@ -1178,13 +1177,15 @@ InstructionCost VPRecipeWithIRFlags::getCostForRecipeWithOpcode(
   case Instruction::Or:
   case Instruction::Xor: {
     // Certain instructions can be cheaper if they have a constant second
-    // operand. One example of this are shifts on x86.
-    VPValue *RHS = getOperand(1);
-    TargetTransformInfo::OperandValueInfo RHSInfo = Ctx.getOperandInfo(RHS);
-
-    if (RHSInfo.Kind == TargetTransformInfo::OK_AnyValue &&
-        getOperand(1)->isDefinedOutsideLoopRegions())
-      RHSInfo.Kind = TargetTransformInfo::OK_UniformValue;
+    // operand. One example of this are shifts on x86. FNeg is the only unary
+    // opcode handled here and has no second operand.
+    TargetTransformInfo::OperandValueInfo RHSInfo;
+    if (Opcode != Instruction::FNeg) {
----------------
david-arm wrote:

Can you use existing routines like `Instruction::isUnaryOp` and `Instruction::isBinaryOp` here to test how many operands there are? It might be more scalable if we add more unary ops here over time.

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


More information about the llvm-commits mailing list