Skip to content

Commit 6d8bc65

Browse files
committed
Auto merge of #154390 - JonathanBrouwer:rollup-y369aHY, r=JonathanBrouwer
Rollup of 3 pull requests Successful merges: - #153068 (Require avxvnni for avx10.2) - #154359 (Add regression test for #154189) - #154386 (Migrate UI tests)
2 parents 1174f78 + c8d729b commit 6d8bc65

6 files changed

Lines changed: 94 additions & 34 deletions

File tree

compiler/rustc_target/src/target_features.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,11 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
392392
"avx512vpopcntdq",
393393
],
394394
),
395-
("avx10.2", Unstable(sym::avx10_target_feature), &["avx10.1"]),
395+
(
396+
"avx10.2",
397+
Unstable(sym::avx10_target_feature),
398+
&["avx10.1", "avxvnni", "avxvnniint8", "avxvnniint16"],
399+
),
396400
("avx512bf16", Stable, &["avx512bw"]),
397401
("avx512bitalg", Stable, &["avx512bw"]),
398402
("avx512bw", Stable, &["avx512f"]),

library/std_detect/src/detect/os/x86.rs

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,28 @@ pub(crate) fn detect_features() -> cache::Initializer {
202202
// Test `XCR0.APX[19]` with the mask `0b1000_0000_0000_0000_0000 == 0x80000`
203203
let os_apx_support = xcr0 & 0x80000 == 0x80000;
204204

205+
if os_amx_support {
206+
enable(extended_features_edx, 24, Feature::amx_tile);
207+
enable(extended_features_edx, 25, Feature::amx_int8);
208+
enable(extended_features_edx, 22, Feature::amx_bf16);
209+
enable(extended_features_eax_leaf_1, 21, Feature::amx_fp16);
210+
enable(extended_features_edx_leaf_1, 8, Feature::amx_complex);
211+
212+
if max_basic_leaf >= 0x1e {
213+
let CpuidResult { eax: amx_feature_flags_eax, .. } =
214+
__cpuid_count(0x1e_u32, 1);
215+
216+
enable(amx_feature_flags_eax, 4, Feature::amx_fp8);
217+
enable(amx_feature_flags_eax, 6, Feature::amx_tf32);
218+
enable(amx_feature_flags_eax, 7, Feature::amx_avx512);
219+
enable(amx_feature_flags_eax, 8, Feature::amx_movrs);
220+
}
221+
}
222+
223+
if os_apx_support {
224+
enable(extended_features_edx_leaf_1, 21, Feature::apxf);
225+
}
226+
205227
// Only if the OS and the CPU support saving/restoring the AVX
206228
// registers we enable `xsave` support:
207229
if os_avx_support {
@@ -236,9 +258,10 @@ pub(crate) fn detect_features() -> cache::Initializer {
236258
enable(extended_features_ebx, 5, Feature::avx2);
237259

238260
// "Short" versions of AVX512 instructions
239-
enable(extended_features_eax_leaf_1, 4, Feature::avxvnni);
240-
enable(extended_features_eax_leaf_1, 23, Feature::avxifma);
241-
enable(extended_features_edx_leaf_1, 4, Feature::avxvnniint8);
261+
let avxvnni = enable(extended_features_eax_leaf_1, 4, Feature::avxvnni);
262+
let avxvnniint8 = enable(extended_features_eax_leaf_1, 23, Feature::avxifma);
263+
let avxvnniint16 =
264+
enable(extended_features_edx_leaf_1, 4, Feature::avxvnniint8);
242265
enable(extended_features_edx_leaf_1, 5, Feature::avxneconvert);
243266
enable(extended_features_edx_leaf_1, 10, Feature::avxvnniint16);
244267

@@ -269,37 +292,18 @@ pub(crate) fn detect_features() -> cache::Initializer {
269292
enable(extended_features_edx, 8, Feature::avx512vp2intersect);
270293
enable(extended_features_edx, 23, Feature::avx512fp16);
271294
enable(extended_features_eax_leaf_1, 5, Feature::avx512bf16);
272-
}
273-
}
274-
275-
if os_amx_support {
276-
enable(extended_features_edx, 24, Feature::amx_tile);
277-
enable(extended_features_edx, 25, Feature::amx_int8);
278-
enable(extended_features_edx, 22, Feature::amx_bf16);
279-
enable(extended_features_eax_leaf_1, 21, Feature::amx_fp16);
280-
enable(extended_features_edx_leaf_1, 8, Feature::amx_complex);
281-
282-
if max_basic_leaf >= 0x1e {
283-
let CpuidResult { eax: amx_feature_flags_eax, .. } =
284-
__cpuid_count(0x1e_u32, 1);
285-
286-
enable(amx_feature_flags_eax, 4, Feature::amx_fp8);
287-
enable(amx_feature_flags_eax, 6, Feature::amx_tf32);
288-
enable(amx_feature_flags_eax, 7, Feature::amx_avx512);
289-
enable(amx_feature_flags_eax, 8, Feature::amx_movrs);
290-
}
291-
}
292-
293-
if os_apx_support {
294-
enable(extended_features_edx_leaf_1, 21, Feature::apxf);
295-
}
296295

297-
let avx10_1 = enable(extended_features_edx_leaf_1, 19, Feature::avx10_1);
298-
if avx10_1 {
299-
let CpuidResult { ebx, .. } = __cpuid(0x24);
300-
let avx10_version = ebx & 0xff;
301-
if avx10_version >= 2 {
302-
value.set(Feature::avx10_2 as u32);
296+
let avx10_1 = enable(extended_features_edx_leaf_1, 19, Feature::avx10_1);
297+
if avx10_1 {
298+
let CpuidResult { ebx, .. } = __cpuid(0x24);
299+
let avx10_version = ebx & 0xff;
300+
301+
// AVX10.2 supports masked versions of dot-product instructions available in avxvnni etc,
302+
// so it doesn't make sense to have it without the unmasked versions
303+
if avx10_version >= 2 && avxvnni && avxvnniint8 && avxvnniint16 {
304+
value.set(Feature::avx10_2 as u32);
305+
}
306+
}
303307
}
304308
}
305309
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! regression test for <https://github.com/rust-lang/rust/issues/17734>
12
//@ run-pass
23
// Test that generating drop glue for Box<str> doesn't ICE
34

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for https://github.com/rust-lang/rust/issues/154189.
2+
#![feature(unboxed_closures)]
3+
4+
trait ToUnit<'a> {
5+
type Unit;
6+
}
7+
8+
impl ToUnit<'_> for *const u32 {
9+
type Unit = ();
10+
}
11+
12+
trait Overlap<T> {}
13+
14+
type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit;
15+
16+
impl<T> Overlap<T> for T {}
17+
18+
impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
19+
//~^ ERROR the trait bound `*const T: ToUnit<'a>` is not satisfied
20+
//~| ERROR the trait bound `T: Overlap<(&'a (), _)>` is not satisfied
21+
22+
fn main() {}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0277]: the trait bound `*const T: ToUnit<'a>` is not satisfied
2+
--> $DIR/generalize-associated-type-alias.rs:18:13
3+
|
4+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T`
6+
|
7+
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
8+
|
9+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T where *const T: ToUnit<'a> {}
10+
| ++++++++++++++++++++++++++
11+
12+
error[E0277]: the trait bound `T: Overlap<(&'a (), _)>` is not satisfied
13+
--> $DIR/generalize-associated-type-alias.rs:18:49
14+
|
15+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
16+
| ^ the trait `Overlap<(&'a (), _)>` is not implemented for `T`
17+
|
18+
help: the trait `Overlap<(&'a (), _)>` is not implemented for `T`
19+
but trait `Overlap<(&(), ())>` is implemented for `u32`
20+
--> $DIR/generalize-associated-type-alias.rs:18:1
21+
|
22+
LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {}
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
= help: for that trait implementation, expected `u32`, found `T`
25+
26+
error: aborting due to 2 previous errors
27+
28+
For more information about this error, try `rustc --explain E0277`.

tests/ui/issues/issue-4735.rs renamed to tests/ui/drop/drop-noncopyable-raw-pointer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! regression test for <https://github.com/rust-lang/rust/issues/4735>
12
//@ run-pass
23

34
use std::mem::transmute;

0 commit comments

Comments
 (0)