Skip to content

Conversation

copybara-service[bot]
Copy link

[opt] Prevent select lifting from pessimizing constant shifts to variable

Modified ProfitabilityGuardForLiftedOp in select_lifting_pass.cc to avoid lifting a select over constant shift amounts (e.g., sel(s, x<<1, x<<2)) into a variable shift (e.g., x << sel(s, 1, 2)). This transformation is almost always unprofitable, since constant shifts can be rewritten to slices & concats with literals (approximately free). This heuristic is only applied when no delay model is provided. If a delay model is present, the existing delay-based profitability analysis is used.

Added new test cases in select_lifting_pass_test.cc to cover:

  • Not lifting constant shifts without a delay model.
  • Lifting when a fake delay model indicates profitability.
  • Not lifting when a fake delay model indicates unprofitability.

#geminiassisted

…able

Modified `ProfitabilityGuardForLiftedOp` in `select_lifting_pass.cc` to avoid lifting a select over constant shift amounts (e.g., `sel(s, x<<1, x<<2)`) into a variable shift (e.g., `x << sel(s, 1, 2)`). This transformation is almost always unprofitable, since constant shifts can be rewritten to slices & concats with literals (approximately free). This heuristic is only applied when no delay model is provided. If a delay model is present, the existing delay-based profitability analysis is used.

Added new test cases in `select_lifting_pass_test.cc` to cover:

*   Not lifting constant shifts without a delay model.
*   Lifting when a fake delay model indicates profitability.
*   Not lifting when a fake delay model indicates unprofitability.

#geminiassisted

PiperOrigin-RevId: 802324592
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant