Skip to content

Commit

Permalink
Rollup merge of rust-lang#82695 - XAMPPRocky:remove-non-power-of-two-…
Browse files Browse the repository at this point in the history
…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```
  • Loading branch information
JohnTitor committed Mar 3, 2021
2 parents 9b58b8b + 5f344a2 commit 64b76da
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 58 deletions.
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Can't be caught in typeck if the array length is generic.
if e_len == 0 {
tcx.sess.fatal(&format!("monomorphising SIMD type `{}` of zero length", ty));
} else if !e_len.is_power_of_two() {
tcx.sess.fatal(&format!(
"monomorphising SIMD type `{}` of non-power-of-two length",
ty
));
} else if e_len > MAX_SIMD_LANES {
tcx.sess.fatal(&format!(
"monomorphising SIMD type `{}` of length greater than {}",
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,15 +1161,6 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
if len == 0 {
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
return;
} else if !len.is_power_of_two() {
struct_span_err!(
tcx.sess,
sp,
E0075,
"SIMD vector length must be a power of two"
)
.emit();
return;
} else if len > MAX_SIMD_LANES {
struct_span_err!(
tcx.sess,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/simd/issue-17170.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// run-pass
#![feature(repr_simd)]

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

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

Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/simd/issue-17170.stderr

This file was deleted.

3 changes: 1 addition & 2 deletions src/test/ui/simd/issue-39720.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// run-pass
// ignore-emscripten FIXME(#45351)

#![feature(repr_simd, platform_intrinsics)]

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

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

extern "platform-intrinsic" {
fn simd_cast<T, U>(x: T) -> U;
Expand Down
15 changes: 0 additions & 15 deletions src/test/ui/simd/issue-39720.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// build-fail
// run-pass

#![feature(repr_simd, platform_intrinsics)]

// error-pattern:monomorphising SIMD type `Simd<3_usize>` of non-power-of-two length

#[repr(simd)]
struct Simd<const N: usize>([f32; N]);

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/ui/simd/simd-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct empty; //~ ERROR SIMD vector cannot be empty
struct empty2([f32; 0]); //~ ERROR SIMD vector cannot be empty

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

#[repr(simd)]
struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous
Expand Down
8 changes: 1 addition & 7 deletions src/test/ui/simd/simd-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ error[E0075]: SIMD vector cannot be empty
LL | struct empty2([f32; 0]);
| ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0075]: SIMD vector length must be a power of two
--> $DIR/simd-type.rs:13:1
|
LL | struct pow2([f32; 7]);
| ^^^^^^^^^^^^^^^^^^^^^^

error[E0076]: SIMD vector should be homogeneous
--> $DIR/simd-type.rs:16:1
|
Expand All @@ -40,7 +34,7 @@ error[E0075]: SIMD vector cannot have more than 32768 elements
LL | struct TooBig([f32; 65536]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 7 previous errors
error: aborting due to 6 previous errors

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

0 comments on commit 64b76da

Please sign in to comment.