Skip to content

Commit afd6754

Browse files
modulovaluedart-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
[vm] Intrinsify Int32x4 operator >>>
Intrinsified on x64, arm64 and arm. ia32 and RISC-V keep the Dart fallback. Issue: #64170 Issue: #64345 Issue: #64511 TEST=lib/typed_data/int32x4_arithmetic_test Change-Id: I1a1637242d4145a4a7c53c56924e625559808a96 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/560562 Commit-Queue: Slava Egorov <vegorov@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
1 parent 7dd74a9 commit afd6754

8 files changed

Lines changed: 27 additions & 6 deletions

File tree

‎runtime/vm/compiler/backend/il.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11312,6 +11312,7 @@ class LoadThreadInstr : public TemplateDefinition<0, NoThrow, PureAndMovable> {
1131211312
M(2, _, Int32x4NotEqual, (Int32x4, Int32x4), Int32x4) \
1131311313
M(2, _, Int32x4Shl, (Int32x4, Int32), Int32x4) \
1131411314
M(2, _, Int32x4ShrS, (Int32x4, Int32), Int32x4) \
11315+
M(2, _, Int32x4ShrU, (Int32x4, Int32), Int32x4) \
1131511316
M(2, _, Int32x4AndNot, (Int32x4, Int32x4), Int32x4) \
1131611317
M(2, _, Float32x4GreaterThan, (Float32x4, Float32x4), Int32x4) \
1131711318
M(2, _, Float32x4GreaterThanOrEqual, (Float32x4, Float32x4), Int32x4) \

‎runtime/vm/compiler/backend/il_arm.cc‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5277,13 +5277,17 @@ DEFINE_EMIT(Int32x4Shift,
52775277
Register shift,
52785278
Temp<QRegister> shift_vector)) {
52795279
__ and_(TMP, shift, compiler::Operand(31));
5280-
if (instr->kind() == SimdOpInstr::kInt32x4ShrS) {
5281-
// vshlqi shifts right when the per-lane count is negative.
5280+
if (instr->kind() != SimdOpInstr::kInt32x4Shl) {
5281+
// vshlqi and vshlqu shift right when the per-lane count is negative.
52825282
__ rsb(TMP, TMP, compiler::Operand(0));
52835283
}
52845284
__ vmovdr(DTMP, 0, TMP);
52855285
__ vdup(compiler::kFourBytes, shift_vector, DTMP, 0);
5286-
__ vshlqi(compiler::kFourBytes, result, value, shift_vector);
5286+
if (instr->kind() == SimdOpInstr::kInt32x4ShrU) {
5287+
__ vshlqu(compiler::kFourBytes, result, value, shift_vector);
5288+
} else {
5289+
__ vshlqi(compiler::kFourBytes, result, value, shift_vector);
5290+
}
52875291
}
52885292

52895293
// Map SimdOpInstr::Kind-s to corresponding emit functions. Uses the following
@@ -5295,6 +5299,7 @@ DEFINE_EMIT(Int32x4Shift,
52955299
#define SIMD_OP_VARIANTS(CASE, ____, SIMPLE) \
52965300
CASE(Int32x4Shl) \
52975301
CASE(Int32x4ShrS) \
5302+
CASE(Int32x4ShrU) \
52985303
____(Int32x4Shift) \
52995304
CASE(Float32x4Add) \
53005305
CASE(Float32x4Sub) \

‎runtime/vm/compiler/backend/il_arm64.cc‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,12 +4380,16 @@ DEFINE_EMIT(Int32x4Shift,
43804380
Temp<Register> count,
43814381
Temp<VRegister> shift_vector)) {
43824382
__ AndImmediate(count, shift, 31);
4383-
if (instr->kind() == SimdOpInstr::kInt32x4ShrS) {
4384-
// SSHL shifts right when the per-lane count is negative.
4383+
if (instr->kind() != SimdOpInstr::kInt32x4Shl) {
4384+
// SSHL and USHL shift right when the per-lane count is negative.
43854385
__ neg(count, count);
43864386
}
43874387
__ vdupw(shift_vector, count);
4388-
__ vsshlw(result, value, shift_vector);
4388+
if (instr->kind() == SimdOpInstr::kInt32x4ShrU) {
4389+
__ vushlw(result, value, shift_vector);
4390+
} else {
4391+
__ vsshlw(result, value, shift_vector);
4392+
}
43894393
}
43904394

43914395
// Map SimdOpInstr::Kind-s to corresponding emit functions. Uses the following
@@ -4397,6 +4401,7 @@ DEFINE_EMIT(Int32x4Shift,
43974401
#define SIMD_OP_VARIANTS(CASE, ____, SIMPLE) \
43984402
CASE(Int32x4Shl) \
43994403
CASE(Int32x4ShrS) \
4404+
CASE(Int32x4ShrU) \
44004405
____(Int32x4Shift) \
44014406
SIMD_OP_SIMPLE_BINARY(CASE) \
44024407
CASE(Float32x4ShuffleMix) \

‎runtime/vm/compiler/backend/il_ia32.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4511,6 +4511,7 @@ LocationSummary* SimdOpInstr::MakeLocationSummary(Zone* zone, bool opt) const {
45114511
case SimdOpInstr::kInt32x4NotEqual:
45124512
case SimdOpInstr::kInt32x4Shl:
45134513
case SimdOpInstr::kInt32x4ShrS:
4514+
case SimdOpInstr::kInt32x4ShrU:
45144515
case SimdOpInstr::kInt32x4AndNot:
45154516
case SimdOpInstr::kFloat32x4GreaterThan:
45164517
case SimdOpInstr::kFloat32x4GreaterThanOrEqual:
@@ -4539,6 +4540,7 @@ void SimdOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
45394540
case SimdOpInstr::kInt32x4NotEqual:
45404541
case SimdOpInstr::kInt32x4Shl:
45414542
case SimdOpInstr::kInt32x4ShrS:
4543+
case SimdOpInstr::kInt32x4ShrU:
45424544
case SimdOpInstr::kInt32x4AndNot:
45434545
case SimdOpInstr::kFloat32x4GreaterThan:
45444546
case SimdOpInstr::kFloat32x4GreaterThanOrEqual:

‎runtime/vm/compiler/backend/il_x64.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,6 +4677,9 @@ DEFINE_EMIT(Int32x4Shift,
46774677
case SimdOpInstr::kInt32x4ShrS:
46784678
__ psrad(value, count_xmm);
46794679
break;
4680+
case SimdOpInstr::kInt32x4ShrU:
4681+
__ psrld(value, count_xmm);
4682+
break;
46804683
default:
46814684
UNREACHABLE();
46824685
}
@@ -4691,6 +4694,7 @@ DEFINE_EMIT(Int32x4Shift,
46914694
#define SIMD_OP_VARIANTS(CASE, ____, SIMPLE) \
46924695
CASE(Int32x4Shl) \
46934696
CASE(Int32x4ShrS) \
4697+
CASE(Int32x4ShrU) \
46944698
____(Int32x4Shift) \
46954699
SIMD_OP_SIMPLE_BINARY(CASE) \
46964700
CASE(Int32x4AndNot) \

‎runtime/vm/compiler/call_specializer.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,6 +2773,7 @@ class SimdLowering : public ValueObject {
27732773
case MethodRecognizer::kInt32x4AllTrue:
27742774
case MethodRecognizer::kInt32x4Shl:
27752775
case MethodRecognizer::kInt32x4ShrS:
2776+
case MethodRecognizer::kInt32x4ShrU:
27762777
case MethodRecognizer::kInt32x4AndNot:
27772778
// TODO(riscv)
27782779
return false;
@@ -3557,6 +3558,7 @@ bool CallSpecializer::TryInlineRecognizedMethod(
35573558
case MethodRecognizer::kInt32x4NotEqual:
35583559
case MethodRecognizer::kInt32x4Shl:
35593560
case MethodRecognizer::kInt32x4ShrS:
3561+
case MethodRecognizer::kInt32x4ShrU:
35603562
case MethodRecognizer::kInt32x4AndNot:
35613563
#endif
35623564
return InlineSimdOp(flow_graph, is_dynamic_call, call, receiver, kind,

‎runtime/vm/compiler/recognized_methods_list.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ namespace dart {
529529
V(TypedDataLibrary, _Int32x4, notEqual, Int32x4NotEqual, 0xafde9ab3) \
530530
V(TypedDataLibrary, _Int32x4, <<, Int32x4Shl, 0xfc92031f) \
531531
V(TypedDataLibrary, _Int32x4, >>, Int32x4ShrS, 0xf0fc5fc4) \
532+
V(TypedDataLibrary, _Int32x4, >>>, Int32x4ShrU, 0xedd3f6c6) \
532533
V(TypedDataLibrary, _Int32x4, get:x, Int32x4GetX, 0x55b951d5) \
533534
V(TypedDataLibrary, _Int32x4, get:y, Int32x4GetY, 0x434aacf8) \
534535
V(TypedDataLibrary, _Int32x4, get:z, Int32x4GetZ, 0x7916188e) \

‎sdk/lib/_internal/vm/lib/typed_data_patch.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,7 @@ final class _Int32x4 implements Int32x4 {
22712271
return Int32x4(x >> n, y >> n, z >> n, w >> n);
22722272
}
22732273

2274+
@pragma("vm:recognized", "other")
22742275
Int32x4 operator >>>(int shiftAmount) {
22752276
final int n = shiftAmount & 31;
22762277
return Int32x4(

0 commit comments

Comments
 (0)