[llvm] [VPlan] Use InstSimplifyFolder in tryToConstantFold (PR #141222)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat May 24 02:17:34 PDT 2025


https://github.com/fhahn commented:

> > Can we drop some of the existing simplifications as a result?
> 
> No, unfortunately. Those matchers match VPValues, which are values in the VPlan overlay, while the constant-folder requires live-ins, or IR values (Value *).

It would indeed be nice if we could use the existing folder for common folds such as `OR x, 1`, but it's currently not possible due to only applying the simplification if all operands are live-ins (i.e. constants in the VPlan sense).

One possible option to use the folder would be to create opaque llvm::Value's for non-live-in operands, pass them to the folder, and if we get one of the opaque values back as result map them back to corresponding the VPValue. But that would probably require at least temporarily modifying the existing IR to materialize opaque values (maybe some kind of load)

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


More information about the llvm-commits mailing list