This is an archive of the discontinued LLVM Phabricator instance.

[Local][InstCombine][GVN] Handle !noundef metadata in combineMetadata
ClosedPublic

Authored by StephenFan on Jan 27 2023, 11:06 PM.

Details

Summary

Handle !noundef metadata in comhineMetadata. The behavior of violating
!noundef metadata is undefined behavior. So if K dominates J, we can
preserve it uncontionally, otherwise, we preserve it if both K and J
have !noundef metadata been set.

This patch also makes !noundef metadata added in KnownIDs when doing
instruction combine for phi node or global value numbering for loads.

Diff Detail

Event Timeline

StephenFan created this revision.Jan 27 2023, 11:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 11:06 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
StephenFan requested review of this revision.Jan 27 2023, 11:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 11:06 PM
nikic added a comment.Jan 28 2023, 1:00 AM

Shouldn't MD_noundef be added to some more known metadata lists, and in particular also combineMetadataForCSE?

Shouldn't MD_noundef be added to some more known metadata lists, and in particular also combineMetadataForCSE?

Yes. Do I need to do it all at once? My original thought was to do it step by step.

nikic added a comment.Jan 28 2023, 8:40 AM

Shouldn't MD_noundef be added to some more known metadata lists, and in particular also combineMetadataForCSE?

Yes. Do I need to do it all at once? My original thought was to do it step by step.

We need to modify at least one place where DoesKMove is false, otherwise we can't fully test the logic.

StephenFan retitled this revision from [Local][InstCombine] Handle !noundef metadata in combineMetadata to [Local][InstCombine][GVN] Handle !noundef metadata in combineMetadata.
StephenFan edited the summary of this revision. (Show Details)

Add test of K dominates J.

nikic accepted this revision.Jan 30 2023, 12:43 AM

LGTM

This revision is now accepted and ready to land.Jan 30 2023, 12:43 AM
This revision was landed with ongoing or failed builds.Feb 1 2023, 10:27 PM
This revision was automatically updated to reflect the committed changes.
nikic added a comment.Feb 21 2023, 1:24 AM

Yes. Do I need to do it all at once? My original thought was to do it step by step.

Do you plan to work on the other combineMetadata() users?

Yes. Do I need to do it all at once? My original thought was to do it step by step.

Do you plan to work on the other combineMetadata() users?

Sorry for the late reply. I will do it these days.