Stream: general

Topic: optimizing cranelift


view this post on Zulip snek (Feb 28 2021 at 03:25):

are there any ways to improve cranelift output? i know there is the speed/size opt setting but even going for best perf the code isn't fantastic. are there maybe like some addon modules which can do better optimizations or something?

view this post on Zulip bjorn3 (Feb 28 2021 at 11:25):

Are you using the new x64 backend or the old x86 backend? When using wasmtime you can enable the former using the "experimental_x64" crate feature. The new x64 backend can result in better output.

view this post on Zulip Andrew Brown (Mar 01 2021 at 18:05):

@snek I have a module to do constant propagation but I can't really upstream it until the IR structs in cranelift-codegen get moved somewhere else (otherwise there is a circular dependency). I can share that module if you're interested, though.

view this post on Zulip snek (Mar 01 2021 at 18:49):

bjorn3 said:

Are you using the new x64 backend or the old x86 backend? When using wasmtime you can enable the former using the "experimental_x64" crate feature. The new x64 backend can result in better output.

not using wasmtime, just cranelift directly (not doing wasm stuff either)

view this post on Zulip snek (Mar 01 2021 at 18:50):

Andrew Brown said:

snek I have a module to do constant propagation but I can't really upstream it until the IR structs in cranelift-codegen get moved somewhere else (otherwise there is a circular dependency). I can share that module if you're interested, though.

sounds cool, is it on gh?

view this post on Zulip Chris Fallin (Mar 01 2021 at 18:52):

snek said:

not using wasmtime, just cranelift directly (not doing wasm stuff either)

It's an option in Cranelift actually, though when using cranelift-codegen directly, you need to build with the x64 feature (x86 is the old backend) and then choose BackendVariant::MachInst when instantiating the backend. @bjorn3's point stands: the new backend will generally produce better code, so it's worth experimenting with if you're not already! We're hoping to make it the default soon, once a few more features are finished.

view this post on Zulip snek (Mar 01 2021 at 18:55):

so i need to stop using the cranelift package, spilt that into cranelift-frontend and cranelift-codegen with x64 feature?

view this post on Zulip Chris Fallin (Mar 01 2021 at 18:58):

Oh, no, you can do all this via cranelift too

view this post on Zulip Chris Fallin (Mar 01 2021 at 18:58):

In that case build with experimental_x64

view this post on Zulip snek (Mar 01 2021 at 18:59):

there is no x64 or experimental_x64 feature for the cranelift crate

view this post on Zulip Chris Fallin (Mar 01 2021 at 18:59):

Urgh, I was looking at cranelift-tools actually, sorry about that

view this post on Zulip Chris Fallin (Mar 01 2021 at 18:59):

Yes, to access the new backend you'll need to depend on the -codegen crate directly


Last updated: Oct 23 2024 at 20:03 UTC