This is an archive of the discontinued LLVM Phabricator instance.

[SCCP] Don't check for UndefValue before calling markConstant()
ClosedPublic

Authored by nikic on Jun 22 2022, 2:54 AM.

Details

Summary

The value lattice explicitly represents undef, and markConstant() internally checks for UndefValue and will create an undef rather than constant lattice element in that case.

This is mostly a code simplification, it has little practical impact because we usually get undef results from undef operands, and those don't get processed.

Only leave the check behind for the CmpInst case, because it currently goes through this incorrect code in the getCompare() implementation: https://github.com/llvm/llvm-project/blob/f98697642cea761448dc0f84f750d3f5def8af6b/llvm/include/llvm/Analysis/ValueLattice.h#L456-L457

Diff Detail

Event Timeline

nikic created this revision.Jun 22 2022, 2:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2022, 2:54 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Jun 22 2022, 2:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2022, 2:54 AM
nikic updated this revision to Diff 441617.Jul 1 2022, 12:17 AM
nikic edited the summary of this revision. (Show Details)

Rebase

fhahn accepted this revision.Jul 13 2022, 11:56 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jul 13 2022, 11:56 AM