FFFF Narrow shift amounts with redundant leading sign bits in NarrowingPass. by copybara-service[bot] · Pull Request #5597 · google/xls · GitHub
[go: up one dir, main page]

Skip to content

Narrow shift amounts with redundant leading sign bits in NarrowingPass. - #5597

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_1031427979
Dec 2, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_1031427979

Conversation

@copybara-service
Copy link
Copy Markdown

Narrow shift amounts with redundant leading sign bits in NarrowingPass.

Shift amounts that come from sign_ext (or selects over sign-extended and zero-extended values) are not narrowed by leading-zero analysis because their upper bits are only known to match the sign bit, leaving narrow-data shifts with wide shift amounts in optimized IR.

Strip redundant leading sign bits from shift amounts in shll, shrl, and shra down to max(amt_width - leading_signs + 1, ceil(log2(data_width)) + 1) when narrower than the leading-zero bound. Non-negative shift amounts drop only zero bits and keep the exact same value; negative shift amounts retain a set MSB with weight at least data_width, so both original and narrowed amounts saturate identically (zero for shll/shrl, sign-fill for shra).

Shift amounts that come from `sign_ext` (or selects over sign-extended and zero-extended values) are not narrowed by leading-zero analysis because their upper bits are only known to match the sign bit, leaving narrow-data shifts with wide shift amounts in optimized IR.

Strip redundant leading sign bits from shift amounts in `shll`, `shrl`, and `shra` down to `max(amt_width - leading_signs + 1, ceil(log2(data_width)) + 1)` when narrower than the leading-zero bound. Non-negative shift amounts drop only zero bits and keep the exact same value; negative shift amounts retain a set MSB with weight at least `data_width`, so both original and narrowed amounts saturate identically (zero for `shll`/`shrl`, sign-fill for `shra`).

PiperOrigin-RevId: 1033976144
@copybara-service
copybara-service Bot merged commit f77a9b3 into main Dec 2, 2026
7 checks passed
@copybara-service
copybara-service Bot deleted the test_1031427979 branch December 2, 2026 01:08

This branch was successfully deployed

1 active deployment
github-pages — f77a9b32 Deployed Dec 2, 2026 by copybara-service[bot] via deploy #15141
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

0