A constant vector that has both undef & poison, e.g., <i8 undef, i8 poison>, isn't UndefValue.
This causes SimplifyQuery::isUndefValue to return false even if it is.
This patch teaches the function to recognize such form as well.
Details
- Reviewers
spatel lebedev.ri nikic fhahn
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/Analysis/InstructionSimplify.h | ||
---|---|---|
146 | Dropping null checks caused assertion failures from the following tests: LLVM :: Transforms/InstCombine/icmp-vec-inseltpoison.ll LLVM :: Transforms/InstCombine/icmp-vec.ll LLVM :: Transforms/InstCombine/select.ll LLVM :: Transforms/InstCombine/sub.ll LLVM :: Transforms/InstCombine/vec_shuffle-inseltpoison.ll LLVM :: Transforms/InstCombine/vec_shuffle.ll LLVM :: Transforms/InstSimplify/2011-09-05-InsertExtractValue.ll LLVM :: Transforms/InstSimplify/pr33957.ll I investigated a few of them and they were mainly due to ConstExpr having vector types. |
This problem isn't really limited to this one function in InstSimplify. Might it make sense to adjust UndefValue to actually represent such constants? We'd have to add a bitmask to it that indicates which values are poison.
Hi,
There is ConstantStruct as well, so to make support that case UndefValue needs to store individual elements, I guess.
What do you think about updating m_Undef pattern matcher to recognize constants like <undef, poison> & replacing isa<UndefValue>(V) with match(V, m_Undef())?
The benefit is that we don't need to add to UndefValue the data structures ConstantAggregate is having.
p.s: BTW, ConstantStruct::get and ConstantArray::getImpl are not returning poison even if all elements are poison. I'll make a commit that applies the change that was made to ConstantVector::getImpl in the past.
I made https://reviews.llvm.org/D100122 to show how the patch would look like if m_Undef is fixed instead.
I'm about to land D100122 instead - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29445 is waiting.
We can revisit this issue if fixing UndefValue is necessary.
clang-tidy: warning: invalid case style for variable 'i' [readability-identifier-naming]
not useful
clang-tidy: warning: invalid case style for variable 'e' [readability-identifier-naming]
not useful