This is an archive of the discontinued LLVM Phabricator instance.

[ConstFolding] Modified algorithm of `ConstantFoldConstantImpl` to be iterative
Needs ReviewPublic

Authored by nikolaypanchenko on Jan 26 2023, 5:41 PM.

Details

Reviewers
arsenm
Summary

Vectorization of the loop may result to huge amount of runtime checks and if host machine has limited stack size, Constant Folding will hit the stack overflow and compilation will crash.
The change modifies the algorithm so that in such environment stack overflow won't happen.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 5:41 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikolaypanchenko published this revision for review.Jan 26 2023, 5:45 PM
nikolaypanchenko added a reviewer: arsenm.
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 5:46 PM
nikic added a subscriber: nikic.Jan 27 2023, 1:35 AM

Patch missing description. What's the motivation for the change?

nikolaypanchenko edited the summary of this revision. (Show Details)Jan 27 2023, 12:05 PM

Patch missing description. What's the motivation for the change?

Added. Cannot add a unit test as it will be too large.

nikic added a comment.Jan 27 2023, 1:00 PM

Can you share how the produced constant expression looks like? Ideally we would not create it in the first place, which we can now do by removing some constant expression operator. I'd be interested in knowing what to target here.