Cranelift: Wrong results in x86_64 and s390x when shifting values of type i16 and i8 #3075
Labels
bug
Incorrect behavior in the current implementation that needs fixing
cranelift:area:s390x
Issues related to Cranelift's s390x backend
cranelift:area:x64
Issues related to x64 codegen
cranelift
Issues related to the Cranelift code generator
Hey, In #3074 we introduce a number of shift tests, some of those found issues with the shift instructions that all backends have.
.clif
Test CaseNote, this is a sample CLIF, we found errors for all shifts with destination types of
i16
andi8
. A full test suite is introduced in #3074, in the files:cranelift/filetests/filetests/runtests/i128-shifts-small-types.clif
cranelift/filetests/filetests/runtests/shifts-small-types.clif
Expected Results and Actual Results
For shift amounts larger than the size of the type, a wrapping behaviour should occur, such that
i32 << 32
is equivalent to performing ai32 << 0
. And this is what happens fori32
andi64
types, however fori16
andi8
this does not happenand the result is always 0.
Versions and Environment
Cranelift version or commit: main
Architecture: x86_64 and s390x
The text was updated successfully, but these errors were encountered: