nox / wg-codegen Goto Github PK
View Code? Open in Web Editor NEWHome of the Rust codegen working group ๐ฅ
License: Apache License 2.0
Home of the Rust codegen working group ๐ฅ
License: Apache License 2.0
Under "Design new MIR-level optimisations", one of the big questions is what kinds of optimizations can be done on MIR. Inlining, constant folding, and expression simplification are obvious candidates.
But if we could rely on Rust's aliasing, and immutable let
s, we could also do basic GVN, LICM, DSE, and others, with relatively little analysis. It wouldn't be a replacement for full SSA and sophisticated analysis (such as LLVM does), but it might be a low-cost way to reduce the amount of code sent to LLVM, and the amount of work LLVM has to do.
To be effective, this needs to work in the presence of unsafe
, or any call which could use unsafe
. I'm aware that the rules for unsafe
are still in development, but would it be possible to assume that this:
pub fn foo(x: &i32, data: &mut [i32]) {
for e in data {
unsafe { /* do your worst, but no UB */ }
*e += *x; // <------ load inside the loop
}
}
is equivalent to this?
pub fn foo(x: &i32, data: &mut [i32]) {
let y = *x; // <------ load outside the loop
for e in data {
unsafe { /* do your worst, but no UB */ }
*e += y;
}
}
If we could do this, then we could do a bunch of other things too.
I made a reddit post a few weeks ago
Sometimes it is really hard to get rustc to autovectorize some code, even with a good memory layout.
For example a few days ago I experimented with sphere / sphere intersection. https://github.com/MaikKlein/hpr/blob/master/src/intersect.rs Nothing comes close to optimal code.
I would like to have a few simple test cases that are guaranteed to autovectorize.
I think the codegen working group's main goal should be the development of the cretonne code generator. The cretonne code generator is primarily written in Rust and a goal for the project is to be a a full optimizing release-capable backend. Putting cretonne in front of the LLVM goals could help make the Rust compiler be written entirely in Rust. I am assuming that people who want to make the Rust compiler faster will want to write Rust instead of C++. Cretonne also seems to be more contributor friendly for Rustaceans of all skill levels LLVM.
Ideas about how the working group could help cretonne
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.