[llvm] [VPlan] Introduce VPlanConstantFolder (PR #125365)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 22 14:05:18 PDT 2025
================
@@ -1047,15 +1049,27 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
R.setOperand(0, Y);
return;
}
+
+ // Constant folding.
+ VPConstantFolder Folder(DL, TypeInfo);
+ TypeSwitch<VPRecipeBase *, void>(&R)
+ .Case<VPInstruction, VPWidenRecipe, VPWidenCastRecipe, VPHistogramRecipe,
+ VPPartialReductionRecipe, VPReplicateRecipe>([&](auto *I) {
+ VPlan *Plan = R.getParent()->getPlan();
+ ArrayRef<VPValue *> Ops{I->op_begin(), I->op_end()};
+ if (Value *V = Folder.tryToConstantFold(R, I->getOpcode(), Ops))
+ R.getVPSingleValue()->replaceAllUsesWith(Plan->getOrAddLiveIn(V));
+ });
----------------
fhahn wrote:
Better to move constant folding up to happen first, to not spend time applying other simplifications that would already be constant folded?
https://github.com/llvm/llvm-project/pull/125365
More information about the llvm-commits
mailing list