Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support bitcasting between scalar and vector types #6104

Open
bjorn3 opened this issue Mar 27, 2023 · 8 comments
Open

Support bitcasting between scalar and vector types #6104

bjorn3 opened this issue Mar 27, 2023 · 8 comments
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:riscv64 Issues related to the RISC-V 64 backend. cranelift:area:s390x Issues related to Cranelift's s390x backend cranelift:area:x64 Issues related to x64 codegen cranelift:E-compiler-easy Beginner–Intermediate compiler issues. cranelift Issues related to the Cranelift code generator

Comments

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 27, 2023

Feature

See title. For example v0 = vconst.i64x2 ...; bitcast.i128 little v0.

Benefit

This allows bitcasting between the two without having to go through memory. Cg_clif needs this bitcasting for implementing mem::transmute and float to 128bit int casts on Windows. Currently it has to go through the stack, which is slower and inhibits optimizations.

@jameysharp jameysharp added the cranelift Issues related to the Cranelift code generator label Mar 27, 2023
@afonso360 afonso360 added the cranelift:E-compiler-easy Beginner–Intermediate compiler issues. label May 23, 2024
@afonso360
Copy link
Contributor

This seems like a good starter issue. It currently affects all of our 4 backends.

Here's a test demonstrating the issue:

test compile
target aarch64

function %bitcast_vec_to_int(i64x2) -> i128 {
block0(v0: i64x2):
    v1 = bitcast.i128 little v0
    return v1
}

function %bitcast_int_to_vec(i128) -> i64x2 {
block0(v0: i128):
    v1 = bitcast.i64x2 little v0
    return v1
}

When running this test it fails with: should be implemented in ISLE: inst = v1 = bitcast.i128 little v0, type = Some(types::I128)

Happy to help anyone who wants to try working on this!

@afonso360 afonso360 added cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen cranelift:area:s390x Issues related to Cranelift's s390x backend cranelift:area:riscv64 Issues related to the RISC-V 64 backend. labels May 23, 2024
@aidenfoxivey
Copy link

@afonso360 It seems like the only remaining part to fix is s390x, right?

@afonso360
Copy link
Contributor

Yes, I think that's correct

@aidenfoxivey
Copy link

Yes, I think that's correct

I'll take a look at how to get a VM running on my ARM MacBook.

@aidenfoxivey
Copy link

Maybe I can take on that remaining part.

@aidenfoxivey
Copy link

aidenfoxivey commented Oct 24, 2024

Signed up for (access/time on) one of those LinuxONE servers from IBM, but no response from them so far lol. I dunno whether maybe QEMU is the preferred approach?

@afonso360
Copy link
Contributor

QEMU is usually easier for working on different arches. We have a great doc on how to set it up if you're running in Linux

@aidenfoxivey
Copy link

QEMU is usually easier for working on different arches. We have a great doc on how to set it up if you're running in Linux

Maybe I'll try to run those in a VM. Unfortunately I'm a Mac person for the time being.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:riscv64 Issues related to the RISC-V 64 backend. cranelift:area:s390x Issues related to Cranelift's s390x backend cranelift:area:x64 Issues related to x64 codegen cranelift:E-compiler-easy Beginner–Intermediate compiler issues. cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

No branches or pull requests

4 participants