This is an archive of the discontinued LLVM Phabricator instance.

[SCEV][NFC] Factor out common API for getting unique operands of a SCEV
ClosedPublic

Authored by mkazantsev on Oct 25 2021, 10:39 PM.

Details

Summary

This function is used at least in 2 places, to it makes sense to make it separate.

Diff Detail

Event Timeline

mkazantsev created this revision.Oct 25 2021, 10:39 PM
mkazantsev requested review of this revision.Oct 25 2021, 10:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 25 2021, 10:39 PM
reames requested changes to this revision.Oct 26 2021, 11:22 AM
reames added inline comments.
llvm/lib/Analysis/ScalarEvolution.cpp
6627

We loose the exit-early with huge operand behavior here.

6642

Please back out the pushOp inlining and just call it here.

This revision now requires changes to proceed.Oct 26 2021, 11:22 AM
mkazantsev marked 2 inline comments as done.
reames accepted this revision.Oct 28 2021, 8:28 AM

LGTM

This revision is now accepted and ready to land.Oct 28 2021, 8:28 AM
nikic added a subscriber: nikic.Oct 28 2021, 10:15 AM

I'm concerned that as-implemented this is could cause non-determinism in edge cases. SmallPtrSet has non-deterministic order, and I think the code in getDefiningScopeBound can be order dependent for cases where scopes with no dominance relation are involved (i.e. neither dominates the other). Do we need the "unique" aspect here? Ideally I'd just return an ArrayRef.

Well, uniqueness is to reduce overhead for the users. If that concerns you, I'll rewrite it into returning vector of unique elements in deterministic order.

mkazantsev planned changes to this revision.Oct 29 2021, 9:58 PM
mkazantsev added a reviewer: nikic.

Addressed Nikita's non-determinism concern.

This revision is now accepted and ready to land.Oct 29 2021, 10:34 PM

To be explicit, still LGTM