llvm-project
807f9b70 - [ConstraintElim] Look for row proving Op <= Max - Slack. (#233851)

Commit
14 days ago
[ConstraintElim] Look for row proving Op <= Max - Slack. (#233851) The constraint system does not record the upper bounds of variables based on the type, so we often fail to prove that a variable Op <= some upper bound in doesHoldInRange. In practice, we frequently have other constraints involving Op and another variable W, which we can use to prove Op is below some bound. To check if `Op <= MaxValue - Slack`, we scan the whole constraint system, looking for rows of the form `Op <= W - Slack`. If W's bitwidth is <= Op's bitwidth, `W <= MaxValue`. Similar reasoning is also applied for `Op >= MinValue + Slack`. This triggers quite widely in practice (5339 files changed in https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1762), while compile-time impact is in the noise, with a small increase in ClamAV (+0.04% worst case): PR: https://github.com/llvm/llvm-project/pull/233851 https://llvm-compile-time-tracker.com/compare.php?from=ce8c2a362e0440be05e7d30129663bd2bf34677f&to=86a0bfaf2610956791d84c91b352582a1bd9b354&stat=instructions:u As an alternative, we could add bounds based on the type for each variable, but constraint-system solving is super-linear in the number of rows, so compile-time impact of that approach is noticeably higher.
Author
Parents
Loading