[llvm] [VPlan] Preserve the branch weights of scalarized selects. (PR #224968)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 06:54:33 PDT 2026
================
@@ -1216,6 +1218,23 @@ static VPValue *simplifyLogicalRecipe(VPlan &Plan, VPSingleDefRecipe *Def) {
return nullptr;
}
+/// Swap the branch weights recorded for \p R, a select whose two selected
+/// operands are being swapped, so that they keep describing the probability of
+/// its condition. Does nothing if there are none, or if they are the marker for
+/// an explicitly unknown profile, which is symmetric.
+static void swapSelectBranchWeights(VPRecipeBase &R, VPlan &Plan) {
+ auto *MD = dyn_cast<VPIRMetadata>(&R);
+ if (!MD)
+ return;
+ SmallVector<uint32_t, 2> Weights;
+ if (!extractBranchWeights(MD->getMetadata(LLVMContext::MD_prof), Weights) ||
+ Weights.size() != 2)
----------------
fhahn wrote:
I don't think we can hit this, turned into an assert, thanks!
https://github.com/llvm/llvm-project/pull/224968
More information about the llvm-commits
mailing list