Skip to content

Commit b4f049d

Browse files
authored
Merge pull request #1735 from ehuss/avx-example
Switch from AVX to SSE in the example
2 parents 708f07f + 639712d commit b4f049d

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Diff for: src/attributes/codegen.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,30 @@ The following restrictions apply unless otherwise specified by the platform rule
9797
Implicitly enabled features are included in this rule. For example an `sse2` function can call ones marked with `sse`.
9898

9999
```rust
100-
# #[cfg(target_feature = "avx2")] {
101-
#[target_feature(enable = "avx")]
102-
fn foo_avx() {}
100+
# #[cfg(target_feature = "sse2")] {
101+
#[target_feature(enable = "sse")]
102+
fn foo_sse() {}
103103

104104
fn bar() {
105-
// Calling `foo_avx` here is unsafe, as we must ensure that AVX is
106-
// available first, even if `avx` is enabled by default on the target
105+
// Calling `foo_sse` here is unsafe, as we must ensure that SSE is
106+
// available first, even if `sse` is enabled by default on the target
107107
// platform or manually enabled as compiler flags.
108108
unsafe {
109-
foo_avx();
109+
foo_sse();
110110
}
111111
}
112112

113-
#[target_feature(enable = "avx")]
114-
fn bar_avx() {
115-
// Calling `foo_avx` here is safe.
116-
foo_avx();
117-
|| foo_avx();
113+
#[target_feature(enable = "sse")]
114+
fn bar_sse() {
115+
// Calling `foo_sse` here is safe.
116+
foo_sse();
117+
|| foo_sse();
118118
}
119119

120-
#[target_feature(enable = "avx2")]
121-
fn bar_avx2() {
122-
// Calling `foo_avx` here is safe because `avx2` implies `avx`.
123-
foo_avx();
120+
#[target_feature(enable = "sse2")]
121+
fn bar_sse2() {
122+
// Calling `foo_sse` here is safe because `sse2` implies `sse`.
123+
foo_sse();
124124
}
125125
# }
126126
```

0 commit comments

Comments
 (0)