This patch changes InstCombine's SimplifyDemandedVectorElts to use PoisonElts instead of UndefElts. It now treats undef elements as DemandedElts and keeps track of poison elements only.
This fixes some undef related bugs marked with LLVM PR44185 in
https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=a9bc405e427c007f.
Such as:
Transforms/InstCombine/insert-const-shuf.ll
Transforms/InstCombine/sub-of-negatible.ll
Transforms/InstCombine/vec_shuffle.ll
At this point, frontends should not be emitting undef values, so losing the undef optimizations should be OK.
In most cases, it should be OK to go from UndefElts to PoisonElts because PoisonElts is a subset of UndefElts.
The only cases that might be of concern are the ones where target specific intrinsics are optimized based on SimplifyDemandedVectorElts.
After this patch they might be emitting poison where there was previously undef. This might break the semantics of those intrinsics. Requesting reviewers for those cases.
This change also allows for more aggressive optimization because poison is more undefined than undef. For example:
gep(X, poison) -> poison is OK gep(X, undef) -> undef is NOT OK. (see https://github.com/llvm/llvm-project/issues/44790)
Previously we weren't allowed to do this because there was no way to distinguish between undef and poison elements.
These optimizations can be done in follow-up patches.
this change doesn't look correct. The bits are undefined, doesn't seem like you can use poison here.