This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Use assume's noundef operand bundle
ClosedPublic

Authored by aqjune on Oct 12 2020, 12:29 AM.

Details

Summary

This patch updates isGuaranteedNotToBeUndefOrPoison to use llvm.assume's noundef operand bundle.

Diff Detail

Event Timeline

aqjune created this revision.Oct 12 2020, 12:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2020, 12:29 AM
aqjune requested review of this revision.Oct 12 2020, 12:29 AM

Weak +1 to using assume operand bundles - it's more friendly for llvm-reduce.

jdoerfert added inline comments.Oct 12 2020, 8:12 AM
llvm/lib/Analysis/ValueTracking.cpp
4843

I thought we had a helper for this, I think it is hasAttributeInAssume in llvm/include/llvm/Analysis/AssumeBundleQueries.h. If that is not enough we should extend it for sure. This kind of query is common and easy to get wrong. For example, this doesn't handle multiple noundef bundles.

Tyker added a comment.Oct 12 2020, 1:15 PM

you probably want to add noundef to isUsefullToPreserve such that it gets preserved automatically when knowledge retention is turned on.

llvm/lib/Analysis/ValueTracking.cpp
4843

there is getKnowledgeValidInContext which should be enough for what is being done here. it also has a fallback when there is no AssumptionCache.
also getOperandBundle is not valid since there maybe more than one noundef bundle in this assume.

aqjune updated this revision to Diff 297813.Oct 13 2020, 3:55 AM

Use getKnowledgeValidInContext

aqjune updated this revision to Diff 297814.Oct 13 2020, 4:00 AM

Add NoUndef to isUsefullToPreserve

aqjune marked 2 inline comments as done.Oct 13 2020, 4:16 AM
aqjune added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
4843

Thanks for the infos!

All of this makes sense to me. Testing coverage is low though.

llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
63

We should have a test for this I think. I imagine inlining a noundef attribute with knowledge retention enabled should actually cause an assume now.

aqjune updated this revision to Diff 298009.Oct 13 2020, 6:49 PM
aqjune marked an inline comment as done.

Add a test

aqjune marked an inline comment as done.Oct 13 2020, 6:50 PM
aqjune added inline comments.
llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
63

It worked, thanks

This revision is now accepted and ready to land.Oct 13 2020, 9:04 PM
This revision was landed with ongoing or failed builds.Oct 14 2020, 4:16 AM
This revision was automatically updated to reflect the committed changes.
aqjune marked an inline comment as done.