On Mon, Jun 23, 2014 at 12:46 AM, comex <com...@gmail.com> wrote: > Second of all, it may be possible to do the checks more efficiently. > I should look at clang's assembly output.
Specifically, for the record, I propose using MPX in the future as a poor man's version of an overflow check instruction. For adding 32-bit integers, you would check whether the result is > 2^32 with a preset bound register (BNDCU instruction, 4 bytes) - admittedly, Rust doesn't use those often... similar goes for 64-bit integers to which a constant is being added (assuming you can hoist the job of loading the negations of those constants into bound registers). For arbitrary 64+64, you'd have to load one of the inputs into a bounds register, which could be more expensive. I have no idea how this will perform when it's released in Skylake; it's more bytes than a jump, but it avoids cluttering the branch predictor. Anyway, it's not exactly far future. (I am also curious about the possibility of improvements on current architectures by doing things like deferring overflow checks... maybe it's not possible in genera though.) _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev