[llvm] [InstCombine] Fixing wrong select folding in vectors with undef elements (PR #102244)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 8 11:12:18 PDT 2024
================
@@ -1735,17 +1735,15 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
APInt DemandedLHS(DemandedElts), DemandedRHS(DemandedElts);
if (auto *CV = dyn_cast<ConstantVector>(Sel->getCondition())) {
for (unsigned i = 0; i < VWidth; i++) {
- // isNullValue() always returns false when called on a ConstantExpr.
- // Skip constant expressions to avoid propagating incorrect information.
Constant *CElt = CV->getAggregateElement(i);
- if (isa<ConstantExpr>(CElt))
- continue;
+
// TODO: If a select condition element is undef, we can demand from
// either side. If one side is known undef, choosing that side would
// propagate undef.
----------------
nikic wrote:
I'd drop this TODO as well.
If we wanted to handle something here it would be poison, in which case we could clear the bit in both vectors.
https://github.com/llvm/llvm-project/pull/102244
More information about the llvm-commits
mailing list