This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Implement impliesPoison
ClosedPublic

Authored by aqjune on Apr 14 2020, 1:46 PM.

Details

Summary

This PR adds impliesPoison(ValAssumedPoison, V) that returns true if V is
poison under the assumption that ValAssumedPoison is poison.

For example, impliesPoison('icmp X, 10', 'icmp X, Y') return true because
'icmp X, Y' is poison if 'icmp X, 10' is poison.

impliesPoison can be used for sound optimization of select, as discussed in
D77868.

Diff Detail

Event Timeline

aqjune created this revision.Apr 14 2020, 1:46 PM
aqjune updated this revision to Diff 258785.Apr 20 2020, 10:17 AM

Remove DT / CtxI as passing them to isGuaranteedNotToBeUndefOrPoison increases compile time

aqjune edited the summary of this revision. (Show Details)Dec 28 2020, 1:04 AM
aqjune updated this revision to Diff 313834.Dec 28 2020, 1:04 AM

Make the function lightweight

nikic accepted this revision.Dec 28 2020, 1:20 PM

LGTM with some nits. Please also fix the clang-tidy warnings wrt const.

There's various ways this could be improved, but I guess we should start simple and see which useful cases slip by.

llvm/lib/Analysis/ValueTracking.cpp
4806

SmallPtrSet

4809

You probably want to leave these two functions next to the main canCreateUndefOrPoison() definition.

4845

count -> contains

llvm/unittests/Analysis/ValueTrackingTest.cpp
703

Why 1u and not true? Or for that matter, EXPECT_TRUE()?

This revision is now accepted and ready to land.Dec 28 2020, 1:20 PM
aqjune marked 4 inline comments as done.Dec 28 2020, 1:51 PM
This revision was landed with ongoing or failed builds.Dec 28 2020, 1:51 PM
This revision was automatically updated to reflect the committed changes.