[llvm] using UNDEF SDNode instead of Constant SDNode when extend the UNDEF SDNode (PR #122741)

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 08:03:51 PST 2025


hubert-reinterpretcast wrote:

> I think we would be able to do this for poison, but not undef. Unfortunately SelectionDAG turns poison into undef.

The IR documentation does not appear to support this. It says

> It is correct to replace a poison value with an [undef value](https://llvm.org/docs/LangRef.html#undefvalues) or any value of the type.

and

> This means that immediate undefined behavior occurs if a poison value is used as an instruction operand that has any values that trigger undefined behavior.

Any replacement of poison of the narrower type with a value (or `undef`) of the narrower type will still leave us with the same situation, and neither the call (which does not have `noundef` on the parameter of interest) nor the `sext`/`zext` conversions have immediate undefined behaviour tied to the `poison` argument of interest.

I think the direction to take here is to see if the middle-end can change the function parameter to be `noext`.


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


More information about the llvm-commits mailing list