Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADX intrinsics on beta don't use ADX instructions #663

Closed
jethrogb opened this issue Jan 31, 2019 · 4 comments
Closed

ADX intrinsics on beta don't use ADX instructions #663

jethrogb opened this issue Jan 31, 2019 · 4 comments
Labels

Comments

@jethrogb
Copy link
Contributor

On nightly, they ICE. See rust-lang/rust#58020

unsafe fn add_1_2_3() -> u32{
    let mut out = 0;
    std::arch::x86_64::_addcarryx_u32(1, 2, 3, &mut out);
    out
}

fn main() {
    if is_x86_feature_detected!("adx") {
        println!("{}", unsafe { add_1_2_3() });
    }
}
$ rustc +beta --version
rustc 1.33.0-beta.3 (4df66ba86 2019-01-21)
$ rustc +beta adx.rs
$ objdump -d adx|grep -A10 -m1 carryx
00000000000060c0 <_ZN4core8coresimd3x863adx14_addcarryx_u3217h27a4e1bbc79875dcE>:
    60c0:	50                   	push   %rax
    60c1:	40 88 f8             	mov    %dil,%al
    60c4:	0f b6 f8             	movzbl %al,%edi
    60c7:	e8 b4 ff ff ff       	callq  6080 <_ZN4core8coresimd3x863adx13_addcarry_u3217hd2ae7a765daf0270E>
    60cc:	88 44 24 07          	mov    %al,0x7(%rsp)
    60d0:	8a 44 24 07          	mov    0x7(%rsp),%al
    60d4:	59                   	pop    %rcx
    60d5:	c3                   	retq   
    60d6:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    60dd:	00 00 00 

As you can see, it just calls the non-ADX version.

@alexcrichton
Copy link
Member

The add_1_2_3 function is missing #[target_feature(enable = "adx")], was that left out by accident?

@jethrogb
Copy link
Contributor Author

@alexcrichton No that's intentional, that's already set on _addcarryx_u32

@gnzlbg gnzlbg added the P-high label Apr 19, 2019
@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 19, 2019

@jethrogb what should this print ? 6 right (2+3+1) ?

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 19, 2019

This works on beta, nightly, and stable now. I've added this test in #731 . Not sure what else to do here. If you have any actionable items let me know.

@gnzlbg gnzlbg closed this as completed Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants