Skip to content

Commit b6f9724

Browse files
authored
Rollup merge of rust-lang#82695 - XAMPPRocky:remove-non-power-of-two-limit, r=nagisa
Revert non-power-of-two vector restriction Removes the power of two restriction from rustc. As discussed in rust-lang/portable-simd#63 r? ``@calebzulawski`` cc ``@workingjubilee`` ``@thomcc``
2 parents a90d462 + 5f344a2 commit b6f9724

10 files changed

+5
-58
lines changed

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
732732
// Can't be caught in typeck if the array length is generic.
733733
if e_len == 0 {
734734
tcx.sess.fatal(&format!("monomorphising SIMD type `{}` of zero length", ty));
735-
} else if !e_len.is_power_of_two() {
736-
tcx.sess.fatal(&format!(
737-
"monomorphising SIMD type `{}` of non-power-of-two length",
738-
ty
739-
));
740735
} else if e_len > MAX_SIMD_LANES {
741736
tcx.sess.fatal(&format!(
742737
"monomorphising SIMD type `{}` of length greater than {}",

compiler/rustc_typeck/src/check/check.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,15 +1161,6 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
11611161
if len == 0 {
11621162
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
11631163
return;
1164-
} else if !len.is_power_of_two() {
1165-
struct_span_err!(
1166-
tcx.sess,
1167-
sp,
1168-
E0075,
1169-
"SIMD vector length must be a power of two"
1170-
)
1171-
.emit();
1172-
return;
11731164
} else if len > MAX_SIMD_LANES {
11741165
struct_span_err!(
11751166
tcx.sess,

src/test/ui/simd/issue-17170.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
// run-pass
12
#![feature(repr_simd)]
23

34
#[repr(simd)]
45
struct T(f64, f64, f64);
5-
//~^ ERROR SIMD vector length must be a power of two
66

77
static X: T = T(0.0, 0.0, 0.0);
88

src/test/ui/simd/issue-17170.stderr

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/test/ui/simd/issue-39720.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
// run-pass
12
// ignore-emscripten FIXME(#45351)
23

34
#![feature(repr_simd, platform_intrinsics)]
45

56
#[repr(simd)]
67
#[derive(Copy, Clone, Debug)]
78
pub struct Char3(pub i8, pub i8, pub i8);
8-
//~^ ERROR SIMD vector length must be a power of two
99

1010
#[repr(simd)]
1111
#[derive(Copy, Clone, Debug)]
1212
pub struct Short3(pub i16, pub i16, pub i16);
13-
//~^ ERROR SIMD vector length must be a power of two
1413

1514
extern "platform-intrinsic" {
1615
fn simd_cast<T, U>(x: T) -> U;

src/test/ui/simd/issue-39720.stderr

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
// build-fail
1+
// run-pass
22

33
#![feature(repr_simd, platform_intrinsics)]
44

5-
// error-pattern:monomorphising SIMD type `Simd<3_usize>` of non-power-of-two length
6-
75
#[repr(simd)]
86
struct Simd<const N: usize>([f32; N]);
97

src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/test/ui/simd/simd-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct empty; //~ ERROR SIMD vector cannot be empty
1010
struct empty2([f32; 0]); //~ ERROR SIMD vector cannot be empty
1111

1212
#[repr(simd)]
13-
struct pow2([f32; 7]); //~ ERROR SIMD vector length must be a power of two
13+
struct pow2([f32; 7]);
1414

1515
#[repr(simd)]
1616
struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous

src/test/ui/simd/simd-type.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ error[E0075]: SIMD vector cannot be empty
1010
LL | struct empty2([f32; 0]);
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error[E0075]: SIMD vector length must be a power of two
14-
--> $DIR/simd-type.rs:13:1
15-
|
16-
LL | struct pow2([f32; 7]);
17-
| ^^^^^^^^^^^^^^^^^^^^^^
18-
1913
error[E0076]: SIMD vector should be homogeneous
2014
--> $DIR/simd-type.rs:16:1
2115
|
@@ -40,7 +34,7 @@ error[E0075]: SIMD vector cannot have more than 32768 elements
4034
LL | struct TooBig([f32; 65536]);
4135
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4236

43-
error: aborting due to 7 previous errors
37+
error: aborting due to 6 previous errors
4438

4539
Some errors have detailed explanations: E0075, E0076, E0077.
4640
For more information about an error, try `rustc --explain E0075`.

0 commit comments

Comments
 (0)