Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upGet LLVM to stop generating dead assembly in next_power_of_two #42556
Conversation
rust-highfive
assigned
BurntSushi
Jun 9, 2017
This comment has been minimized.
This comment has been minimized.
|
r? @BurntSushi (rust_highfive has picked a reviewer for you, use r? to override) |
kennytm
reviewed
Jun 9, 2017
src/librustc_trans/intrinsic.rs
Outdated
| @@ -280,6 +280,11 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, | |||
| let llfn = ccx.get_intrinsic(&format!("llvm.{}.i{}", name, width)); | |||
| bcx.call(llfn, &[llargs[0], y], None) | |||
| } | |||
| "ctlz_nonzero" | "cttz_nonzero" => { | |||
| let y = C_bool(bcx.ccx, true); | |||
| let llfn = ccx.get_intrinsic(&format!("llvm.{}.i{}", &name[..4], width)); | |||
This comment has been minimized.
This comment has been minimized.
kennytm
Jun 9, 2017
Member
[00:03:22] tidy error: /checkout/src/librustc_trans/intrinsic.rs:285: line longer than 100 chars
This comment has been minimized.
This comment has been minimized.
scottmcm
Jun 9, 2017
Author
Member
Yup; currently waiting on local double-check for the fix. Thanks for the targeted comment!
scottmcm
added some commits
May 28, 2017
scottmcm
force-pushed the
scottmcm:ctz-nz
branch
from
c13a31a
to
6d86f0c
Jun 9, 2017
This comment has been minimized.
This comment has been minimized.
|
LGTM. Thanks! @bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
shepmaster
added
the
S-waiting-on-bors
label
Jun 9, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jun 10, 2017
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 6d86f0c
into
rust-lang:master
Jun 10, 2017
scottmcm
deleted the
scottmcm:ctz-nz
branch
Jun 21, 2017
scottmcm
referenced this pull request
Aug 3, 2017
Merged
Add `align_offset` intrinsic and `[T]::align_to` function #2043
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
scottmcm commentedJun 9, 2017
It turns out that LLVM can turn
@llvm.ctlz.i64(_, true)into@llvm.ctlz.i64(_, false)(ctlz) where valuable, but never does the opposite. That leads to some silly assembly getting generated in certain cases.A contrived-but-clear example https://is.gd/VAIKuC:
Generates
I noticed this in
next_power_of_two, which without this PR generates the following:And with this PR becomes