Skip to content

Commit ecbb33a

Browse files
committed
Implement and fix a couple more simd intrinsics
1 parent f6ba10d commit ecbb33a

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

scripts/test_rustc_tests.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ rm tests/ui/parser/unclosed-delimiter-in-dep.rs # submodule contains //~ERROR
3636
# FIXME add needs-unwind to this test
3737
rm -r tests/run-make/libtest-junit
3838

39+
# extra warning about -Cpanic=abort for proc macros
40+
rm tests/ui/proc-macro/crt-static.rs
41+
rm tests/ui/proc-macro/proc-macro-deprecated-attr.rs
42+
rm tests/ui/proc-macro/quote-debug.rs
43+
rm tests/ui/proc-macro/no-missing-docs.rs
44+
rm tests/ui/rust-2018/proc-macro-crate-in-paths.rs
45+
rm tests/ui/proc-macro/allowed-signatures.rs
46+
3947
# vendor intrinsics
4048
rm tests/ui/sse2.rs # cpuid not supported, so sse2 not detected
4149
rm tests/ui/intrinsics/const-eval-select-x86_64.rs # requires x86_64 vendor intrinsics
@@ -111,13 +119,6 @@ rm tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs # same
111119
rm tests/ui/suggestions/derive-trait-for-method-call.rs # same
112120
rm tests/ui/typeck/issue-46112.rs # same
113121

114-
rm tests/ui/proc-macro/crt-static.rs # extra warning about -Cpanic=abort for proc macros
115-
rm tests/ui/proc-macro/proc-macro-deprecated-attr.rs # same
116-
rm tests/ui/proc-macro/quote-debug.rs # same
117-
rm tests/ui/proc-macro/no-missing-docs.rs # same
118-
rm tests/ui/rust-2018/proc-macro-crate-in-paths.rs # same
119-
rm tests/ui/proc-macro/allowed-signatures.rs # same
120-
121122
# rustdoc-clif passes extra args, suppressing the help message when no args are passed
122123
rm -r tests/run-make/issue-88756-default-output
123124

@@ -132,9 +133,7 @@ rm -r tests/ui/consts/missing_span_in_backtrace.rs # expects sysroot source to b
132133
rm tests/incremental/spike-neg1.rs # errors out for some reason
133134
rm tests/incremental/spike-neg2.rs # same
134135

135-
rm tests/ui/simd/intrinsic/generic-reduction-pass.rs # simd_reduce_add_unordered doesn't accept an accumulator for integer vectors
136-
137-
rm tests/ui/simd/simd-bitmask.rs # crash
136+
rm tests/ui/simd/simd-bitmask.rs # simd_bitmask doesn't implement [u*; N] return type
138137

139138
rm -r tests/run-make/issue-51671 # wrong filename given in case of --emit=obj
140139
rm -r tests/run-make/issue-30063 # same

src/intrinsics/simd.rs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
488488
});
489489
}
490490

491-
sym::simd_reduce_add_ordered | sym::simd_reduce_add_unordered => {
491+
sym::simd_reduce_add_ordered => {
492492
intrinsic_args!(fx, args => (v, acc); intrinsic);
493493
let acc = acc.load_scalar(fx);
494494

@@ -507,7 +507,25 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
507507
});
508508
}
509509

510-
sym::simd_reduce_mul_ordered | sym::simd_reduce_mul_unordered => {
510+
sym::simd_reduce_add_unordered => {
511+
intrinsic_args!(fx, args => (v); intrinsic);
512+
513+
// FIXME there must be no acc param for integer vectors
514+
if !v.layout().ty.is_simd() {
515+
report_simd_type_validation_error(fx, intrinsic, span, v.layout().ty);
516+
return;
517+
}
518+
519+
simd_reduce(fx, v, None, ret, &|fx, lane_ty, a, b| {
520+
if lane_ty.is_floating_point() {
521+
fx.bcx.ins().fadd(a, b)
522+
} else {
523+
fx.bcx.ins().iadd(a, b)
524+
}
525+
});
526+
}
527+
528+
sym::simd_reduce_mul_ordered => {
511529
intrinsic_args!(fx, args => (v, acc); intrinsic);
512530
let acc = acc.load_scalar(fx);
513531

@@ -526,6 +544,24 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
526544
});
527545
}
528546

547+
sym::simd_reduce_mul_unordered => {
548+
intrinsic_args!(fx, args => (v); intrinsic);
549+
550+
// FIXME there must be no acc param for integer vectors
551+
if !v.layout().ty.is_simd() {
552+
report_simd_type_validation_error(fx, intrinsic, span, v.layout().ty);
553+
return;
554+
}
555+
556+
simd_reduce(fx, v, None, ret, &|fx, lane_ty, a, b| {
557+
if lane_ty.is_floating_point() {
558+
fx.bcx.ins().fmul(a, b)
559+
} else {
560+
fx.bcx.ins().imul(a, b)
561+
}
562+
});
563+
}
564+
529565
sym::simd_reduce_all => {
530566
intrinsic_args!(fx, args => (v); intrinsic);
531567

@@ -581,7 +617,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
581617
simd_reduce(fx, v, None, ret, &|fx, _ty, a, b| fx.bcx.ins().bxor(a, b));
582618
}
583619

584-
sym::simd_reduce_min => {
620+
sym::simd_reduce_min | sym::simd_reduce_min_nanless => {
585621
intrinsic_args!(fx, args => (v); intrinsic);
586622

587623
if !v.layout().ty.is_simd() {
@@ -600,7 +636,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
600636
});
601637
}
602638

603-
sym::simd_reduce_max => {
639+
sym::simd_reduce_max | sym::simd_reduce_max_nanless => {
604640
intrinsic_args!(fx, args => (v); intrinsic);
605641

606642
if !v.layout().ty.is_simd() {
@@ -878,6 +914,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
878914
fx.tcx.sess.span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic));
879915
// Prevent verifier error
880916
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
917+
return;
881918
}
882919
}
883920
let ret_block = fx.get_block(target);

0 commit comments

Comments
 (0)