This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Let getGuaranteedNonPoisonOp find multiple non-poison operands
ClosedPublic

Authored by aqjune on Aug 24 2020, 10:47 AM.

Details

Summary

This patch helps getGuaranteedNonPoisonOp find multiple non-poison operands.

Another patch that adds noundef to Intrinsics.td will be uploaded.

Diff Detail

Event Timeline

aqjune created this revision.Aug 24 2020, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2020, 10:47 AM
aqjune requested review of this revision.Aug 24 2020, 10:47 AM
nikic added inline comments.Aug 24 2020, 1:03 PM
llvm/lib/Analysis/ValueTracking.cpp
5123–5130

We don't really care about duplicates in this context, so I'd suggest a more efficient SmallVector.

5128

This should be the other way around, i.e. iterate over NonPoisonOps and check if they are in KnownPoison. The NonPoisonOps set is generally expected to be smaller than the KnownPoison one.

aqjune updated this revision to Diff 287537.Aug 24 2020, 5:46 PM

Iterate over NonPoisonOps

aqjune updated this revision to Diff 287540.Aug 24 2020, 5:58 PM
aqjune marked an inline comment as done.

Use SmallPtrSet

aqjune added inline comments.Aug 24 2020, 5:59 PM
llvm/lib/Analysis/ValueTracking.cpp
5123–5130

I think set is beneficial for its use at PoisonChecking - it allows introducing one check for one value.
Instead I changed its type to SmallPtrSet as it seems to be more efficient.

jdoerfert accepted this revision.Aug 25 2020, 10:39 AM

LGTM.

Instead of special-casing llvm.assume, I think it is also a viable option to add noundef to Intrinsics.td. If it makes sense, I'll make a patch for that.

I think that makes sense.

llvm/include/llvm/Analysis/ValueTracking.h
590

Nit: SmallPtrSetImpl

llvm/lib/Analysis/ValueTracking.cpp
5111

The function pointer too, but unclear if that helps much ;)

This revision is now accepted and ready to land.Aug 25 2020, 10:39 AM
aqjune added inline comments.Aug 25 2020, 11:10 AM
llvm/lib/Analysis/ValueTracking.cpp
5111

I think that's a valid point, I'll add it.

aqjune updated this revision to Diff 287754.Aug 25 2020, 12:39 PM

Use SmallPtrSetImpl, consider function pointers

aqjune edited the summary of this revision. (Show Details)Aug 25 2020, 12:39 PM
This revision was landed with ongoing or failed builds.Aug 25 2020, 12:40 PM
This revision was automatically updated to reflect the committed changes.