graal
graal copied to clipboard
Fix bit shifting behavior in LLVM back-end, as per Java specifications
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA). The following contributors of this PR have not signed the OCA:
- PR author: @koutheir
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.
When singing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.
I already signed the OCA months ago.
Do you have an example where the LLVM backend behaviour is different from the expected one?
I encountered this issue in a JCK test. I don't remember which one it was, but I remember it was testing negative shifts behavior.
I've tried to reproduce this but the result is consistent with the Java spec, so I'd like to be sure that we actually need this before adding an instruction to every shift that's emitted.
Notice that negative shifts are only well-defined in Java. C designates shifts that are negative or higher than the number of bits as undefined behavior. LLVM does not support negative shifts, and reinterprets any negative shifts as unsigned integers, which is different from the Java behavior (no modulo).