Skip to content

Conversation

@mmha
Copy link
Collaborator

@mmha mmha commented Apr 17, 2025

Negative shift amounts are undefined behavior in C and C++. Because of that we can always zero-extend the shift amount which is slightly faster on certain architectures (e. g. x86). This also matches the behavior of the original clang Codegen.

Backported from llvm/llvm-project#133405

Negative shift amounts are undefined behavior in C and C++. Because of
that we can always zero-extend the shift amount which is slightly faster
on certain architectures (e. g. x86). This also matches the behavior of
the original clang Codegen.
@bcardosolopes bcardosolopes changed the title Always zero-extend shift amounts [CIR] Always zero-extend shift amounts Apr 17, 2025
@bcardosolopes
Copy link
Member

Thanks!!

@bcardosolopes bcardosolopes merged commit 90833a4 into llvm:main Apr 17, 2025
10 checks passed
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
Negative shift amounts are undefined behavior in C and C++. Because of
that we can always zero-extend the shift amount which is slightly faster
on certain architectures (e. g. x86). This also matches the behavior of
the original clang Codegen.

Backported from llvm/llvm-project#133405

Co-authored-by: Morris Hafner <mhafner@nvidia.com>
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.

2 participants