[llvm] DAG: Preserve poison in some cast folds (PR #225403)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 01:01:41 PDT 2026


bjope wrote:

Ok, so it is ReplaceAllUsesWith that can create nodes without using getNode. And therefore one kind of need to duplicate lots of folds from getNode in DAGCombiner. That is a bit sad from a code duplication point of view. And it makes it difficult to spot things like folds in getNode and DAGCombine not doing the same thing.

I've often found the getNode folds a bit weird. As you for example would expect to get a CONCAT_VECTOR node back when creating a CONCAT_VECTOR, and not something completely different such as a BUILD_VECTOR. You can't create a SDValue with getNode and assume that you got what you asked for.

I guess the main idea is to optimize compiler speed, avoiding to create nodes that would be simplified later anyway(?). But I don't know how much we gain if DAGCombiner also implement the same folds (sometimes it would be a waste doing the same checks twice).

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


More information about the llvm-commits mailing list