[PATCH] D92717: [InstCombine] Fix miscompile into uadd.sat (PR48390)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 01:25:12 PST 2020
lebedev.ri added a comment.
Please can you precommit the tests?
The fix looks like it just workarounds the problem, which is elsewhere.
Let me know if i should commandeer the revision.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:766-786
// Match unsigned saturated add of 2 variables with an unnecessary 'not'.
// There are 8 commuted variants.
// Canonicalize -1 (saturated result) to true value of the select. Just
// swapping the compare operands is legal, because the selected value is the
// same in case of equality, so we can interchange u< and u<=.
+ bool Swapped = false;
if (match(FVal, m_AllOnes())) {
----------------
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:806-808
+ // The overflow may be detected via the add wrapping round. Which is only
+ // valid if we did not swap the true and false values.
+ if (!Swapped && match(Cmp0, m_c_Add(m_Specific(Cmp1), m_Value(Y))) &&
----------------
Undo this
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92717/new/
https://reviews.llvm.org/D92717
More information about the llvm-commits
mailing list