Skip to content

Commit 07db2bf

Browse files
committed
Implement floating point SIMD intrinsics over all vector widths, and limit SIMD vector lengths.
1 parent fd85ca0 commit 07db2bf

10 files changed

+141
-199
lines changed

compiler/rustc_codegen_llvm/src/context.rs

-117
Original file line numberDiff line numberDiff line change
@@ -498,25 +498,6 @@ impl CodegenCx<'b, 'tcx> {
498498
let t_f32 = self.type_f32();
499499
let t_f64 = self.type_f64();
500500

501-
macro_rules! vector_types {
502-
($id_out:ident: $elem_ty:ident, $len:expr) => {
503-
let $id_out = self.type_vector($elem_ty, $len);
504-
};
505-
($($id_out:ident: $elem_ty:ident, $len:expr;)*) => {
506-
$(vector_types!($id_out: $elem_ty, $len);)*
507-
}
508-
}
509-
vector_types! {
510-
t_v2f32: t_f32, 2;
511-
t_v4f32: t_f32, 4;
512-
t_v8f32: t_f32, 8;
513-
t_v16f32: t_f32, 16;
514-
515-
t_v2f64: t_f64, 2;
516-
t_v4f64: t_f64, 4;
517-
t_v8f64: t_f64, 8;
518-
}
519-
520501
ifn!("llvm.wasm.trunc.saturate.unsigned.i32.f32", fn(t_f32) -> t_i32);
521502
ifn!("llvm.wasm.trunc.saturate.unsigned.i32.f64", fn(t_f64) -> t_i32);
522503
ifn!("llvm.wasm.trunc.saturate.unsigned.i64.f32", fn(t_f32) -> t_i64);
@@ -540,149 +521,51 @@ impl CodegenCx<'b, 'tcx> {
540521
ifn!("llvm.sideeffect", fn() -> void);
541522

542523
ifn!("llvm.powi.f32", fn(t_f32, t_i32) -> t_f32);
543-
ifn!("llvm.powi.v2f32", fn(t_v2f32, t_i32) -> t_v2f32);
544-
ifn!("llvm.powi.v4f32", fn(t_v4f32, t_i32) -> t_v4f32);
545-
ifn!("llvm.powi.v8f32", fn(t_v8f32, t_i32) -> t_v8f32);
546-
ifn!("llvm.powi.v16f32", fn(t_v16f32, t_i32) -> t_v16f32);
547524
ifn!("llvm.powi.f64", fn(t_f64, t_i32) -> t_f64);
548-
ifn!("llvm.powi.v2f64", fn(t_v2f64, t_i32) -> t_v2f64);
549-
ifn!("llvm.powi.v4f64", fn(t_v4f64, t_i32) -> t_v4f64);
550-
ifn!("llvm.powi.v8f64", fn(t_v8f64, t_i32) -> t_v8f64);
551525

552526
ifn!("llvm.pow.f32", fn(t_f32, t_f32) -> t_f32);
553-
ifn!("llvm.pow.v2f32", fn(t_v2f32, t_v2f32) -> t_v2f32);
554-
ifn!("llvm.pow.v4f32", fn(t_v4f32, t_v4f32) -> t_v4f32);
555-
ifn!("llvm.pow.v8f32", fn(t_v8f32, t_v8f32) -> t_v8f32);
556-
ifn!("llvm.pow.v16f32", fn(t_v16f32, t_v16f32) -> t_v16f32);
557527
ifn!("llvm.pow.f64", fn(t_f64, t_f64) -> t_f64);
558-
ifn!("llvm.pow.v2f64", fn(t_v2f64, t_v2f64) -> t_v2f64);
559-
ifn!("llvm.pow.v4f64", fn(t_v4f64, t_v4f64) -> t_v4f64);
560-
ifn!("llvm.pow.v8f64", fn(t_v8f64, t_v8f64) -> t_v8f64);
561528

562529
ifn!("llvm.sqrt.f32", fn(t_f32) -> t_f32);
563-
ifn!("llvm.sqrt.v2f32", fn(t_v2f32) -> t_v2f32);
564-
ifn!("llvm.sqrt.v4f32", fn(t_v4f32) -> t_v4f32);
565-
ifn!("llvm.sqrt.v8f32", fn(t_v8f32) -> t_v8f32);
566-
ifn!("llvm.sqrt.v16f32", fn(t_v16f32) -> t_v16f32);
567530
ifn!("llvm.sqrt.f64", fn(t_f64) -> t_f64);
568-
ifn!("llvm.sqrt.v2f64", fn(t_v2f64) -> t_v2f64);
569-
ifn!("llvm.sqrt.v4f64", fn(t_v4f64) -> t_v4f64);
570-
ifn!("llvm.sqrt.v8f64", fn(t_v8f64) -> t_v8f64);
571531

572532
ifn!("llvm.sin.f32", fn(t_f32) -> t_f32);
573-
ifn!("llvm.sin.v2f32", fn(t_v2f32) -> t_v2f32);
574-
ifn!("llvm.sin.v4f32", fn(t_v4f32) -> t_v4f32);
575-
ifn!("llvm.sin.v8f32", fn(t_v8f32) -> t_v8f32);
576-
ifn!("llvm.sin.v16f32", fn(t_v16f32) -> t_v16f32);
577533
ifn!("llvm.sin.f64", fn(t_f64) -> t_f64);
578-
ifn!("llvm.sin.v2f64", fn(t_v2f64) -> t_v2f64);
579-
ifn!("llvm.sin.v4f64", fn(t_v4f64) -> t_v4f64);
580-
ifn!("llvm.sin.v8f64", fn(t_v8f64) -> t_v8f64);
581534

582535
ifn!("llvm.cos.f32", fn(t_f32) -> t_f32);
583-
ifn!("llvm.cos.v2f32", fn(t_v2f32) -> t_v2f32);
584-
ifn!("llvm.cos.v4f32", fn(t_v4f32) -> t_v4f32);
585-
ifn!("llvm.cos.v8f32", fn(t_v8f32) -> t_v8f32);
586-
ifn!("llvm.cos.v16f32", fn(t_v16f32) -> t_v16f32);
587536
ifn!("llvm.cos.f64", fn(t_f64) -> t_f64);
588-
ifn!("llvm.cos.v2f64", fn(t_v2f64) -> t_v2f64);
589-
ifn!("llvm.cos.v4f64", fn(t_v4f64) -> t_v4f64);
590-
ifn!("llvm.cos.v8f64", fn(t_v8f64) -> t_v8f64);
591537

592538
ifn!("llvm.exp.f32", fn(t_f32) -> t_f32);
593-
ifn!("llvm.exp.v2f32", fn(t_v2f32) -> t_v2f32);
594-
ifn!("llvm.exp.v4f32", fn(t_v4f32) -> t_v4f32);
595-
ifn!("llvm.exp.v8f32", fn(t_v8f32) -> t_v8f32);
596-
ifn!("llvm.exp.v16f32", fn(t_v16f32) -> t_v16f32);
597539
ifn!("llvm.exp.f64", fn(t_f64) -> t_f64);
598-
ifn!("llvm.exp.v2f64", fn(t_v2f64) -> t_v2f64);
599-
ifn!("llvm.exp.v4f64", fn(t_v4f64) -> t_v4f64);
600-
ifn!("llvm.exp.v8f64", fn(t_v8f64) -> t_v8f64);
601540

602541
ifn!("llvm.exp2.f32", fn(t_f32) -> t_f32);
603-
ifn!("llvm.exp2.v2f32", fn(t_v2f32) -> t_v2f32);
604-
ifn!("llvm.exp2.v4f32", fn(t_v4f32) -> t_v4f32);
605-
ifn!("llvm.exp2.v8f32", fn(t_v8f32) -> t_v8f32);
606-
ifn!("llvm.exp2.v16f32", fn(t_v16f32) -> t_v16f32);
607542
ifn!("llvm.exp2.f64", fn(t_f64) -> t_f64);
608-
ifn!("llvm.exp2.v2f64", fn(t_v2f64) -> t_v2f64);
609-
ifn!("llvm.exp2.v4f64", fn(t_v4f64) -> t_v4f64);
610-
ifn!("llvm.exp2.v8f64", fn(t_v8f64) -> t_v8f64);
611543

612544
ifn!("llvm.log.f32", fn(t_f32) -> t_f32);
613-
ifn!("llvm.log.v2f32", fn(t_v2f32) -> t_v2f32);
614-
ifn!("llvm.log.v4f32", fn(t_v4f32) -> t_v4f32);
615-
ifn!("llvm.log.v8f32", fn(t_v8f32) -> t_v8f32);
616-
ifn!("llvm.log.v16f32", fn(t_v16f32) -> t_v16f32);
617545
ifn!("llvm.log.f64", fn(t_f64) -> t_f64);
618-
ifn!("llvm.log.v2f64", fn(t_v2f64) -> t_v2f64);
619-
ifn!("llvm.log.v4f64", fn(t_v4f64) -> t_v4f64);
620-
ifn!("llvm.log.v8f64", fn(t_v8f64) -> t_v8f64);
621546

622547
ifn!("llvm.log10.f32", fn(t_f32) -> t_f32);
623-
ifn!("llvm.log10.v2f32", fn(t_v2f32) -> t_v2f32);
624-
ifn!("llvm.log10.v4f32", fn(t_v4f32) -> t_v4f32);
625-
ifn!("llvm.log10.v8f32", fn(t_v8f32) -> t_v8f32);
626-
ifn!("llvm.log10.v16f32", fn(t_v16f32) -> t_v16f32);
627548
ifn!("llvm.log10.f64", fn(t_f64) -> t_f64);
628-
ifn!("llvm.log10.v2f64", fn(t_v2f64) -> t_v2f64);
629-
ifn!("llvm.log10.v4f64", fn(t_v4f64) -> t_v4f64);
630-
ifn!("llvm.log10.v8f64", fn(t_v8f64) -> t_v8f64);
631549

632550
ifn!("llvm.log2.f32", fn(t_f32) -> t_f32);
633-
ifn!("llvm.log2.v2f32", fn(t_v2f32) -> t_v2f32);
634-
ifn!("llvm.log2.v4f32", fn(t_v4f32) -> t_v4f32);
635-
ifn!("llvm.log2.v8f32", fn(t_v8f32) -> t_v8f32);
636-
ifn!("llvm.log2.v16f32", fn(t_v16f32) -> t_v16f32);
637551
ifn!("llvm.log2.f64", fn(t_f64) -> t_f64);
638-
ifn!("llvm.log2.v2f64", fn(t_v2f64) -> t_v2f64);
639-
ifn!("llvm.log2.v4f64", fn(t_v4f64) -> t_v4f64);
640-
ifn!("llvm.log2.v8f64", fn(t_v8f64) -> t_v8f64);
641552

642553
ifn!("llvm.fma.f32", fn(t_f32, t_f32, t_f32) -> t_f32);
643-
ifn!("llvm.fma.v2f32", fn(t_v2f32, t_v2f32, t_v2f32) -> t_v2f32);
644-
ifn!("llvm.fma.v4f32", fn(t_v4f32, t_v4f32, t_v4f32) -> t_v4f32);
645-
ifn!("llvm.fma.v8f32", fn(t_v8f32, t_v8f32, t_v8f32) -> t_v8f32);
646-
ifn!("llvm.fma.v16f32", fn(t_v16f32, t_v16f32, t_v16f32) -> t_v16f32);
647554
ifn!("llvm.fma.f64", fn(t_f64, t_f64, t_f64) -> t_f64);
648-
ifn!("llvm.fma.v2f64", fn(t_v2f64, t_v2f64, t_v2f64) -> t_v2f64);
649-
ifn!("llvm.fma.v4f64", fn(t_v4f64, t_v4f64, t_v4f64) -> t_v4f64);
650-
ifn!("llvm.fma.v8f64", fn(t_v8f64, t_v8f64, t_v8f64) -> t_v8f64);
651555

652556
ifn!("llvm.fabs.f32", fn(t_f32) -> t_f32);
653-
ifn!("llvm.fabs.v2f32", fn(t_v2f32) -> t_v2f32);
654-
ifn!("llvm.fabs.v4f32", fn(t_v4f32) -> t_v4f32);
655-
ifn!("llvm.fabs.v8f32", fn(t_v8f32) -> t_v8f32);
656-
ifn!("llvm.fabs.v16f32", fn(t_v16f32) -> t_v16f32);
657557
ifn!("llvm.fabs.f64", fn(t_f64) -> t_f64);
658-
ifn!("llvm.fabs.v2f64", fn(t_v2f64) -> t_v2f64);
659-
ifn!("llvm.fabs.v4f64", fn(t_v4f64) -> t_v4f64);
660-
ifn!("llvm.fabs.v8f64", fn(t_v8f64) -> t_v8f64);
661558

662559
ifn!("llvm.minnum.f32", fn(t_f32, t_f32) -> t_f32);
663560
ifn!("llvm.minnum.f64", fn(t_f64, t_f64) -> t_f64);
664561
ifn!("llvm.maxnum.f32", fn(t_f32, t_f32) -> t_f32);
665562
ifn!("llvm.maxnum.f64", fn(t_f64, t_f64) -> t_f64);
666563

667564
ifn!("llvm.floor.f32", fn(t_f32) -> t_f32);
668-
ifn!("llvm.floor.v2f32", fn(t_v2f32) -> t_v2f32);
669-
ifn!("llvm.floor.v4f32", fn(t_v4f32) -> t_v4f32);
670-
ifn!("llvm.floor.v8f32", fn(t_v8f32) -> t_v8f32);
671-
ifn!("llvm.floor.v16f32", fn(t_v16f32) -> t_v16f32);
672565
ifn!("llvm.floor.f64", fn(t_f64) -> t_f64);
673-
ifn!("llvm.floor.v2f64", fn(t_v2f64) -> t_v2f64);
674-
ifn!("llvm.floor.v4f64", fn(t_v4f64) -> t_v4f64);
675-
ifn!("llvm.floor.v8f64", fn(t_v8f64) -> t_v8f64);
676566

677567
ifn!("llvm.ceil.f32", fn(t_f32) -> t_f32);
678-
ifn!("llvm.ceil.v2f32", fn(t_v2f32) -> t_v2f32);
679-
ifn!("llvm.ceil.v4f32", fn(t_v4f32) -> t_v4f32);
680-
ifn!("llvm.ceil.v8f32", fn(t_v8f32) -> t_v8f32);
681-
ifn!("llvm.ceil.v16f32", fn(t_v16f32) -> t_v16f32);
682568
ifn!("llvm.ceil.f64", fn(t_f64) -> t_f64);
683-
ifn!("llvm.ceil.v2f64", fn(t_v2f64) -> t_v2f64);
684-
ifn!("llvm.ceil.v4f64", fn(t_v4f64) -> t_v4f64);
685-
ifn!("llvm.ceil.v8f64", fn(t_v8f64) -> t_v8f64);
686569

687570
ifn!("llvm.trunc.f32", fn(t_f32) -> t_f32);
688571
ifn!("llvm.trunc.f64", fn(t_f64) -> t_f64);

compiler/rustc_codegen_llvm/src/intrinsic.rs

+55-78
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ fn generic_simd_intrinsic(
10091009
}
10101010

10111011
fn simd_simple_float_intrinsic(
1012-
name: &str,
1012+
name: Symbol,
10131013
in_elem: &::rustc_middle::ty::TyS<'_>,
10141014
in_ty: &::rustc_middle::ty::TyS<'_>,
10151015
in_len: u64,
@@ -1036,93 +1036,70 @@ fn generic_simd_intrinsic(
10361036
}
10371037
}
10381038
}
1039-
let ety = match in_elem.kind() {
1040-
ty::Float(f) if f.bit_width() == 32 => {
1041-
if in_len < 2 || in_len > 16 {
1042-
return_error!(
1043-
"unsupported floating-point vector `{}` with length `{}` \
1044-
out-of-range [2, 16]",
1045-
in_ty,
1046-
in_len
1047-
);
1048-
}
1049-
"f32"
1050-
}
1051-
ty::Float(f) if f.bit_width() == 64 => {
1052-
if in_len < 2 || in_len > 8 {
1039+
1040+
let (elem_ty_str, elem_ty) = if let ty::Float(f) = in_elem.kind() {
1041+
let elem_ty = bx.cx.type_float_from_ty(*f);
1042+
match f.bit_width() {
1043+
32 => ("f32", elem_ty),
1044+
64 => ("f64", elem_ty),
1045+
_ => {
10531046
return_error!(
1054-
"unsupported floating-point vector `{}` with length `{}` \
1055-
out-of-range [2, 8]",
1056-
in_ty,
1057-
in_len
1047+
"unsupported element type `{}` of floating-point vector `{}`",
1048+
f.name_str(),
1049+
in_ty
10581050
);
10591051
}
1060-
"f64"
1061-
}
1062-
ty::Float(f) => {
1063-
return_error!(
1064-
"unsupported element type `{}` of floating-point vector `{}`",
1065-
f.name_str(),
1066-
in_ty
1067-
);
1068-
}
1069-
_ => {
1070-
return_error!("`{}` is not a floating-point type", in_ty);
10711052
}
1053+
} else {
1054+
return_error!("`{}` is not a floating-point type", in_ty);
10721055
};
10731056

1074-
let llvm_name = &format!("llvm.{0}.v{1}{2}", name, in_len, ety);
1075-
let intrinsic = bx.get_intrinsic(&llvm_name);
1076-
let c =
1077-
bx.call(intrinsic, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None);
1057+
let vec_ty = bx.type_vector(elem_ty, in_len);
1058+
1059+
let (intr_name, fn_ty) = match name {
1060+
sym::simd_fsqrt => ("sqrt", bx.type_func(&[vec_ty], vec_ty)),
1061+
sym::simd_fsin => ("sin", bx.type_func(&[vec_ty], vec_ty)),
1062+
sym::simd_fcos => ("cos", bx.type_func(&[vec_ty], vec_ty)),
1063+
sym::simd_fabs => ("fabs", bx.type_func(&[vec_ty], vec_ty)),
1064+
sym::simd_floor => ("floor", bx.type_func(&[vec_ty], vec_ty)),
1065+
sym::simd_ceil => ("ceil", bx.type_func(&[vec_ty], vec_ty)),
1066+
sym::simd_fexp => ("exp", bx.type_func(&[vec_ty], vec_ty)),
1067+
sym::simd_fexp2 => ("exp2", bx.type_func(&[vec_ty], vec_ty)),
1068+
sym::simd_flog10 => ("log10", bx.type_func(&[vec_ty], vec_ty)),
1069+
sym::simd_flog2 => ("log2", bx.type_func(&[vec_ty], vec_ty)),
1070+
sym::simd_flog => ("log", bx.type_func(&[vec_ty], vec_ty)),
1071+
sym::simd_fpowi => ("powi", bx.type_func(&[vec_ty, bx.type_i32()], vec_ty)),
1072+
sym::simd_fpow => ("pow", bx.type_func(&[vec_ty, vec_ty], vec_ty)),
1073+
sym::simd_fma => ("fma", bx.type_func(&[vec_ty, vec_ty, vec_ty], vec_ty)),
1074+
_ => return_error!("unrecognized intrinsic `{}`", name),
1075+
};
1076+
1077+
let llvm_name = &format!("llvm.{0}.v{1}{2}", intr_name, in_len, elem_ty_str);
1078+
let f = bx.declare_cfn(&llvm_name, fn_ty);
1079+
llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No);
1080+
let c = bx.call(f, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None);
10781081
unsafe { llvm::LLVMRustSetHasUnsafeAlgebra(c) };
10791082
Ok(c)
10801083
}
10811084

1082-
match name {
1083-
sym::simd_fsqrt => {
1084-
return simd_simple_float_intrinsic("sqrt", in_elem, in_ty, in_len, bx, span, args);
1085-
}
1086-
sym::simd_fsin => {
1087-
return simd_simple_float_intrinsic("sin", in_elem, in_ty, in_len, bx, span, args);
1088-
}
1089-
sym::simd_fcos => {
1090-
return simd_simple_float_intrinsic("cos", in_elem, in_ty, in_len, bx, span, args);
1091-
}
1092-
sym::simd_fabs => {
1093-
return simd_simple_float_intrinsic("fabs", in_elem, in_ty, in_len, bx, span, args);
1094-
}
1095-
sym::simd_floor => {
1096-
return simd_simple_float_intrinsic("floor", in_elem, in_ty, in_len, bx, span, args);
1097-
}
1098-
sym::simd_ceil => {
1099-
return simd_simple_float_intrinsic("ceil", in_elem, in_ty, in_len, bx, span, args);
1100-
}
1101-
sym::simd_fexp => {
1102-
return simd_simple_float_intrinsic("exp", in_elem, in_ty, in_len, bx, span, args);
1103-
}
1104-
sym::simd_fexp2 => {
1105-
return simd_simple_float_intrinsic("exp2", in_elem, in_ty, in_len, bx, span, args);
1106-
}
1107-
sym::simd_flog10 => {
1108-
return simd_simple_float_intrinsic("log10", in_elem, in_ty, in_len, bx, span, args);
1109-
}
1110-
sym::simd_flog2 => {
1111-
return simd_simple_float_intrinsic("log2", in_elem, in_ty, in_len, bx, span, args);
1112-
}
1113-
sym::simd_flog => {
1114-
return simd_simple_float_intrinsic("log", in_elem, in_ty, in_len, bx, span, args);
1115-
}
1116-
sym::simd_fpowi => {
1117-
return simd_simple_float_intrinsic("powi", in_elem, in_ty, in_len, bx, span, args);
1118-
}
1119-
sym::simd_fpow => {
1120-
return simd_simple_float_intrinsic("pow", in_elem, in_ty, in_len, bx, span, args);
1121-
}
1122-
sym::simd_fma => {
1123-
return simd_simple_float_intrinsic("fma", in_elem, in_ty, in_len, bx, span, args);
1124-
}
1125-
_ => { /* fallthrough */ }
1085+
if std::matches!(
1086+
name,
1087+
sym::simd_fsqrt
1088+
| sym::simd_fsin
1089+
| sym::simd_fcos
1090+
| sym::simd_fabs
1091+
| sym::simd_floor
1092+
| sym::simd_ceil
1093+
| sym::simd_fexp
1094+
| sym::simd_fexp2
1095+
| sym::simd_flog10
1096+
| sym::simd_flog2
1097+
| sym::simd_flog
1098+
| sym::simd_fpowi
1099+
| sym::simd_fpow
1100+
| sym::simd_fma
1101+
) {
1102+
return simd_simple_float_intrinsic(name, in_elem, in_ty, in_len, bx, span, args);
11261103
}
11271104

11281105
// FIXME: use:

compiler/rustc_middle/src/ty/layout.rs

+7
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,17 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
694694
};
695695

696696
// SIMD vectors of zero length are not supported.
697+
// Additionally, lengths are capped at 2^16 as a fixed maximum backends must
698+
// support.
697699
//
698700
// Can't be caught in typeck if the array length is generic.
699701
if e_len == 0 {
700702
tcx.sess.fatal(&format!("monomorphising SIMD type `{}` of zero length", ty));
703+
} else if e_len > 65536 {
704+
tcx.sess.fatal(&format!(
705+
"monomorphising SIMD type `{}` of length greater than 65536",
706+
ty,
707+
));
701708
}
702709

703710
// Compute the ABI of the element type:

compiler/rustc_typeck/src/check/check.rs

+22
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,28 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
10981098
.emit();
10991099
return;
11001100
}
1101+
1102+
let len = if let ty::Array(_ty, c) = e.kind() {
1103+
c.try_eval_usize(tcx, tcx.param_env(def.did))
1104+
} else {
1105+
Some(fields.len() as u64)
1106+
};
1107+
if let Some(len) = len {
1108+
if len == 0 {
1109+
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
1110+
return;
1111+
} else if len > 65536 {
1112+
struct_span_err!(
1113+
tcx.sess,
1114+
sp,
1115+
E0075,
1116+
"SIMD vector cannot have more than 65536 elements"
1117+
)
1118+
.emit();
1119+
return;
1120+
}
1121+
}
1122+
11011123
match e.kind() {
11021124
ty::Param(_) => { /* struct<T>(T, T, T, T) is ok */ }
11031125
_ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// build-fail
2+
3+
#![feature(repr_simd, platform_intrinsics)]
4+
5+
// error-pattern:monomorphising SIMD type `Simd<0_usize>` of zero length
6+
7+
#[repr(simd)]
8+
struct Simd<const N: usize>([f32; N]);
9+
10+
fn main() {
11+
let _ = Simd::<0>([]);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: monomorphising SIMD type `Simd<0_usize>` of zero length
2+
3+
error: aborting due to previous error
4+

0 commit comments

Comments
 (0)