wasmtime icon indicating copy to clipboard operation
wasmtime copied to clipboard

cranelift: Support `bnot`, `band`, `bor`, `bxor` for x86_64.

Open ArtBlnd opened this issue 2 years ago • 4 comments

This patch implements float bitops on x86_64 using SSE instructions. @afonso360

  • [x] Check if better single slot bitops available on x86_64. (which has better latency or throughput?...)
  • [ ] Make single slot mask for f32, f64 instead of vector_all_ones

ArtBlnd avatar Oct 09 '22 23:10 ArtBlnd

WIP right now. Some masks on the bitops are invalid. trying to fix it.

ArtBlnd avatar Oct 09 '22 23:10 ArtBlnd

I think there is no better options for single float bitops instruction on x86_64. (at least on SSE)

ArtBlnd avatar Oct 10 '22 17:10 ArtBlnd

first of all, I need to make test for float to vec to check that unused bits are filtered out. bnot operation may generate incorrect code because current bnot implementation does use vector_all_ones which will flip all unused bits. means it has side-effect.

so I am finding a efficient way to generate single slot bit mask. (not using load ops. that will need extra stack allocations.)

https://github.com/bytecodealliance/wasmtime/pull/5036/files#diff-4fb30cf23cc13cba2f11079dc6d0305f972170585aab27b27d143c2f3252e4faR1270-R1274

ArtBlnd avatar Oct 18 '22 20:10 ArtBlnd

You can tag me once you're ready for review; I glanced over this and it made sense.

abrown avatar Oct 18 '22 21:10 abrown

I think there is no cheap way to generate masks...

~~maybe we need to truncate all unused vector slots when using scalar_to_vector~~ ~~I'll make seperate PR for this task.~~

nevermind. scalar_to_vector is using movss, movsd.

ArtBlnd avatar Oct 22 '22 18:10 ArtBlnd

@abrown I think its ready to review.

ArtBlnd avatar Oct 22 '22 19:10 ArtBlnd

sorry for the very late response for the review.

ArtBlnd avatar Nov 03 '22 02:11 ArtBlnd

@ArtBlnd, I believe the CI failure here is due to some rustc changes between when this PR was open and now. Can you rebase this PR and see if that resolves things?

abrown avatar Nov 10 '22 19:11 abrown

@ArtBlnd, I believe the CI failure here is due to some rustc changes between when this PR was open and now. Can you rebase this PR and see if that resolves things?

Done.

ArtBlnd avatar Nov 18 '22 04:11 ArtBlnd