[llvm] [VPlan] Model cost of safe-divisor in VPlan (PR #154468)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 01:47:35 PDT 2025


================
@@ -7949,6 +7949,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,
       VPValue *One =
           Plan.getOrAddLiveIn(ConstantInt::get(I->getType(), 1u, false));
       auto *SafeRHS = Builder.createSelect(Mask, Ops[1], One, I->getDebugLoc());
+      SafeRHS->setUnderlyingValue(I);
----------------
david-arm wrote:

Will this confuse `VPSlotTracker::assignName`, since there will be two VPValues with the same underlying value? I guess it also means that the select would be ignored along with the div in both `calculateRegisterUsageForPlan` and `VPRecipeBase::cost`, which perhaps isn't a bad thing?

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


More information about the llvm-commits mailing list