This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fix miscompile into uadd.sat (PR48390)
ClosedPublic

Authored by lebedev.ri on Dec 5 2020, 3:41 AM.

Details

Summary

We could create uadd.sat under incorrect circumstances if a select with -1 as the false value was canonicalized by swapping the T/F values. Unlike the other transforms in the same function, it is not invariant to equality.

Some alive proofs: https://alive2.llvm.org/ce/z/emmKKL
Fixes PR48390

Diff Detail

Event Timeline

dmgreen created this revision.Dec 5 2020, 3:41 AM
dmgreen requested review of this revision.Dec 5 2020, 3:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2020, 3:41 AM
lebedev.ri retitled this revision from [IC] Fix invalid creation of uadd.sat to [InstCombine] Fix miscompile into uadd.sat (PR48390).Dec 7 2020, 12:48 AM
lebedev.ri edited the summary of this revision. (Show Details)
lebedev.ri added a reviewer: lebedev.ri.
lebedev.ri set the repository for this revision to rG LLVM Github Monorepo.

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.

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
766–782
805–808

Undo this

Let me know if i should commandeer the revision.

Yeah sure, feel free to go ahead.

lebedev.ri commandeered this revision.Dec 7 2020, 11:17 PM
lebedev.ri edited reviewers, added: dmgreen; removed: lebedev.ri.
This revision was not accepted when it landed; it landed in state Needs Review.Dec 9 2020, 7:19 AM
This revision was automatically updated to reflect the committed changes.

Ok, after all, this was roughly similar to what i ended up with, sorry for taking this over..