[llvm] [VPlan] Introduce VPlanConstantFolder (PR #125365)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 12:56:10 PST 2025


================
@@ -0,0 +1,91 @@
+//===- VPlanConstantFolder.h - ConstantFolder for VPlan -------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "VPlanValue.h"
+#include "llvm/IR/ConstantFolder.h"
+
+namespace llvm {
+class VPConstantFolder {
+private:
+  ConstantFolder Folder;
+
+  Constant *getIRConstant(VPValue *V) const {
+    return dyn_cast_if_present<Constant>(V->getUnderlyingValue());
----------------
artagnon wrote:

Oh, I saw that this wasn't true in practice, and even put up https://github.com/llvm/llvm-project/pull/128886, which includes some improvements. I do have a question though: isn't the defining recipe created with several intermediate Builder-create calls? Why should the defining recipe be present when we're in the process of building recipes?

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


More information about the llvm-commits mailing list