Skip to content

'fma' is missing in target-feature #40406

New issue

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

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

Already on GitHub? # to your account

Closed
fsasm opened this issue Mar 10, 2017 · 2 comments · Fixed by #40431
Closed

'fma' is missing in target-feature #40406

fsasm opened this issue Mar 10, 2017 · 2 comments · Fixed by #40431

Comments

@fsasm
Copy link
Contributor

fsasm commented Mar 10, 2017

When setting target-feature=+fma and printing the features via --print cfg only avx and sse* are listed as target features. Also queries like #[cfg(target_feature = "fma")] do not detect fma. FMA instructions like x86_mm256_fmadd_ps are only usable when fma is enable via target-feature as expected.

The output of rustc -C target-feature=+fma --print cfg is

debug_assertions
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="avx"
target_feature="sse"
target_feature="sse2"
target_feature="sse3"
target_feature="sse4.1"
target_feature="sse4.2"
target_feature="ssse3"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_os="linux"
target_pointer_width="64"
target_thread_local
target_vendor="unknown"
unix

and the expected output is

[...]
target_feature="fma"
target_feature="avx"
target_feature="sse"
target_feature="sse2"
target_feature="sse3"
target_feature="sse4.1"
target_feature="sse4.2"
target_feature="ssse3"
[...]

Also this example

#![feature(cfg_target_feature)]

fn main() {
    #[cfg(target_feature = "fma")]
    println!("FMA is supported");

    #[cfg(not(target_feature = "fma"))]
    println!("FMA is not supported");
}

outputs FMA is not supported even if it was enabled.

Meta

rustc --version --verbose:
rustc 1.17.0-nightly (b1e3176 2017-03-03)
binary: rustc
commit-hash: b1e3176
commit-date: 2017-03-03
host: x86_64-unknown-linux-gnu
release: 1.17.0-nightly
LLVM version: 3.9

@nagisa
Copy link
Member

nagisa commented Mar 10, 2017

Rustc does not expose all the LLVM features via attributes consciously. Not a bug. If you want it added your best bet is to make a PR.

@fsasm
Copy link
Contributor Author

fsasm commented Mar 10, 2017

Wouldn't it be better to output a warning in such a case?

arielb1 pushed a commit to arielb1/rust that referenced this issue Mar 11, 2017
rustc: Whitelist the FMA target feature

This commit adds the entry `"fma\0"` to the whitelist for the x86
target. LLVM already supports fma but rustc did not directly. Previously
rustc permitted `+fma` in the target-feature argument and enabled the use
of FMA instructions, but it did not list it in the configuration and
attributes.

fixes rust-lang#40406
arielb1 pushed a commit to arielb1/rust that referenced this issue Mar 11, 2017
rustc: Whitelist the FMA target feature

This commit adds the entry `"fma\0"` to the whitelist for the x86
target. LLVM already supports fma but rustc did not directly. Previously
rustc permitted `+fma` in the target-feature argument and enabled the use
of FMA instructions, but it did not list it in the configuration and
attributes.

fixes rust-lang#40406
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants