about summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-06-08 07:20:57 +0000
committerbors <bors@rust-lang.org>2019-06-08 07:20:57 +0000
commit7f90abe3aa1864e40e3d516b936c4a1a84e72aee (patch)
treec7f2291af4dbdb983fa7f5fdd6941b90dde084c4 /src/libsyntax/ext/expand.rs
parent6312b89fdabce0aedf613391266e08c0deef2324 (diff)
parentf6611db1d59bbf5fb7d5cfbcccc629b6916d06a3 (diff)
downloadrust-7f90abe3aa1864e40e3d516b936c4a1a84e72aee.tar.gz
rust-7f90abe3aa1864e40e3d516b936c4a1a84e72aee.zip
Auto merge of #61635 - ecstatic-morse:const-signum, r=oli-obk
Make `i*::signum` a `const fn`.

Ticks a box in #53718.

This uses a well-known branchless implementation of `signum`: `(n > 0) as i32 - (n < 0) as i32`.

Here's a [playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=747cf191c4974bf66c9d75e509ae6e6e) comparing the two techniques. On x86 in release mode, the branchless implementation is able to replace a `mov` and `cmov` with a `sar` and `add`, so this should be a bit faster as well.

~~This is marked as a draft since I think I'll need to add `#[rustc_const_unstable]` somewhere. Perhaps the reviewer can point me in the right direction.~~
Diffstat (limited to 'src/libsyntax/ext/expand.rs')
0 files changed, 0 insertions, 0 deletions