This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Limit max recursion in `isKnownNeverZero` and `isKnownToBeAPowerOfTwo`
ClosedPublic

Authored by goldstein.w.n on Apr 25 2023, 2:26 PM.

Details

Summary

Both of these functions recursively call themselves so it makes sense
to limit that upper bound.

Diff Detail

Event Timeline

goldstein.w.n created this revision.Apr 25 2023, 2:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 2:26 PM
goldstein.w.n requested review of this revision.Apr 25 2023, 2:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 2:26 PM
craig.topper added inline comments.Apr 25 2023, 10:09 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
4068–4069

This is missing a depth too?

foad added a subscriber: foad.Apr 26 2023, 12:09 AM
foad added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
5060–5062

Need to pass Depth into the recursive calls, otherwise what's the point?

goldstein.w.n marked 2 inline comments as done.Apr 26 2023, 2:48 PM

Use Depth in all recursive calls

RKSimon added inline comments.Apr 27 2023, 3:41 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
4023

In the existing SelectionDAG recursion methods, we don't increment Depth here but in the recursive calls to make it more obvious (and avoids any messy Depth - 1 hacks)

goldstein.w.n marked an inline comment as done.May 12 2023, 10:08 PM

Use common style

RKSimon accepted this revision.May 13 2023, 3:26 AM

LGTM - cheers

This revision is now accepted and ready to land.May 13 2023, 3:26 AM
This revision was landed with ongoing or failed builds.May 13 2023, 12:36 PM
This revision was automatically updated to reflect the committed changes.