diff options
author | Nikita Popov <npopov@redhat.com> | 2024-04-18 15:44:12 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-18 15:44:12 +0900 |
commit | 1baa3850656382d1d549a13f8a716ef5dc886eb8 (patch) | |
tree | 9aa3086c00912cecf5489b14ef4bbba04390a625 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 7ec342ba16ca97206aa2ddd5b7ec0da063042e03 (diff) | |
download | llvm-1baa3850656382d1d549a13f8a716ef5dc886eb8.zip llvm-1baa3850656382d1d549a13f8a716ef5dc886eb8.tar.gz llvm-1baa3850656382d1d549a13f8a716ef5dc886eb8.tar.bz2 |
[IR][PatternMatch] Only accept poison in getSplatValue() (#89159)
In #88217 a large set of matchers was changed to only accept poison
values in splats, but not undef values. This is because we now use
poison for non-demanded vector elements, and allowing undef can cause
correctness issues.
This patch covers the remaining matchers by changing the AllowUndef
parameter of getSplatValue() to AllowPoison instead. We also carry out
corresponding renames in matchers.
As a followup, we may want to change the default for things like m_APInt
to m_APIntAllowPoison (as this is much less risky when only allowing
poison), but this change doesn't do that.
There is one caveat here: We have a single place
(X86FixupVectorConstants) which does require handling of vector splats
with undefs. This is because this works on backend constant pool
entries, which currently still use undef instead of poison for
non-demanded elements (because SDAG as a whole does not have an explicit
poison representation). As it's just the single use, I've open-coded a
getSplatValueAllowUndef() helper there, to discourage use in any other
places.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 695d0b0..b87bba7 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -4116,7 +4116,7 @@ std::pair<Value *, FPClassTest> llvm::fcmpToClassTest(FCmpInst::Predicate Pred, Value *LHS, Value *RHS, bool LookThroughSrc) { const APFloat *ConstRHS; - if (!match(RHS, m_APFloatAllowUndef(ConstRHS))) + if (!match(RHS, m_APFloatAllowPoison(ConstRHS))) return {nullptr, fcAllFlags}; return fcmpToClassTest(Pred, F, LHS, ConstRHS, LookThroughSrc); @@ -4517,7 +4517,7 @@ std::tuple<Value *, FPClassTest, FPClassTest> llvm::fcmpImpliesClass(CmpInst::Predicate Pred, const Function &F, Value *LHS, Value *RHS, bool LookThroughSrc) { const APFloat *ConstRHS; - if (!match(RHS, m_APFloatAllowUndef(ConstRHS))) + if (!match(RHS, m_APFloatAllowPoison(ConstRHS))) return {nullptr, fcAllFlags, fcAllFlags}; // TODO: Just call computeKnownFPClass for RHS to handle non-constants. |