Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 51373004: SIMD shuffle API changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index da6de7b43d8396a6575921ab953fcb9b6f76d634..03cb9ff9fc247f5fc19ad3e904c8ad78496a14bb 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -1683,10 +1683,18 @@ bool FlowGraphOptimizer::InlineFloat32x4Getter(InstanceCallInstr* call,
call->env(),
call);
intptr_t mask = 0;
- if (getter == MethodRecognizer::kFloat32x4Shuffle) {
+ if ((getter == MethodRecognizer::kFloat32x4Shuffle) ||
+ (getter == MethodRecognizer::kFloat32x4ShuffleMix)) {
// Extract shuffle mask.
- ASSERT(call->ArgumentCount() == 2);
- Definition* mask_definition = call->ArgumentAt(1);
+ Definition* mask_definition = NULL;
+ if (getter == MethodRecognizer::kFloat32x4Shuffle) {
+ ASSERT(call->ArgumentCount() == 2);
+ mask_definition = call->ArgumentAt(1);
+ } else {
+ ASSERT(getter == MethodRecognizer::kFloat32x4ShuffleMix);
+ ASSERT(call->ArgumentCount() == 3);
+ mask_definition = call->ArgumentAt(2);
+ }
if (!mask_definition->IsConstant()) {
// Not a constant.
return false;
@@ -1712,13 +1720,22 @@ bool FlowGraphOptimizer::InlineFloat32x4Getter(InstanceCallInstr* call,
call->deopt_id());
ReplaceCall(call, instr);
return true;
+ } else if (getter == MethodRecognizer::kFloat32x4ShuffleMix) {
+ Simd32x4ShuffleMixInstr* instr = new Simd32x4ShuffleMixInstr(
+ getter,
+ new Value(call->ArgumentAt(0)),
+ new Value(call->ArgumentAt(1)),
+ mask,
+ call->deopt_id());
+ ReplaceCall(call, instr);
+ return true;
} else {
ASSERT((getter == MethodRecognizer::kFloat32x4Shuffle) ||
(getter == MethodRecognizer::kFloat32x4ShuffleX) ||
(getter == MethodRecognizer::kFloat32x4ShuffleY) ||
(getter == MethodRecognizer::kFloat32x4ShuffleZ) ||
(getter == MethodRecognizer::kFloat32x4ShuffleW));
- Float32x4ShuffleInstr* instr = new Float32x4ShuffleInstr(
+ Simd32x4ShuffleInstr* instr = new Simd32x4ShuffleInstr(
getter,
new Value(call->ArgumentAt(0)),
mask,
@@ -1742,6 +1759,37 @@ bool FlowGraphOptimizer::InlineUint32x4Getter(InstanceCallInstr* call,
call->deopt_id(),
call->env(),
call);
+ intptr_t mask = 0;
+ if ((getter == MethodRecognizer::kUint32x4Shuffle) ||
+ (getter == MethodRecognizer::kUint32x4ShuffleMix)) {
+ // Extract shuffle mask.
+ Definition* mask_definition = NULL;
+ if (getter == MethodRecognizer::kUint32x4Shuffle) {
+ ASSERT(call->ArgumentCount() == 2);
+ mask_definition = call->ArgumentAt(1);
+ } else {
+ ASSERT(getter == MethodRecognizer::kUint32x4ShuffleMix);
+ ASSERT(call->ArgumentCount() == 3);
+ mask_definition = call->ArgumentAt(2);
+ }
+ if (!mask_definition->IsConstant()) {
+ // Not a constant.
+ return false;
+ }
+ ASSERT(mask_definition->IsConstant());
+ ConstantInstr* constant_instruction = mask_definition->AsConstant();
+ const Object& constant_mask = constant_instruction->value();
+ if (!constant_mask.IsSmi()) {
+ // Not a smi.
+ return false;
+ }
+ ASSERT(constant_mask.IsSmi());
+ mask = Smi::Cast(constant_mask).Value();
+ if (mask < 0 || mask > 255) {
+ // Not a valid mask.
+ return false;
+ }
+ }
if (getter == MethodRecognizer::kUint32x4GetSignMask) {
Simd32x4GetSignMaskInstr* instr = new Simd32x4GetSignMaskInstr(
getter,
@@ -1749,6 +1797,23 @@ bool FlowGraphOptimizer::InlineUint32x4Getter(InstanceCallInstr* call,
call->deopt_id());
ReplaceCall(call, instr);
return true;
+ } else if (getter == MethodRecognizer::kUint32x4ShuffleMix) {
+ Simd32x4ShuffleMixInstr* instr = new Simd32x4ShuffleMixInstr(
+ getter,
+ new Value(call->ArgumentAt(0)),
+ new Value(call->ArgumentAt(1)),
+ mask,
+ call->deopt_id());
+ ReplaceCall(call, instr);
+ return true;
+ } else if (getter == MethodRecognizer::kUint32x4Shuffle) {
+ Simd32x4ShuffleInstr* instr = new Simd32x4ShuffleInstr(
+ getter,
+ new Value(call->ArgumentAt(0)),
+ mask,
+ call->deopt_id());
+ ReplaceCall(call, instr);
+ return true;
} else {
Uint32x4GetFlagInstr* instr = new Uint32x4GetFlagInstr(
getter,
@@ -2306,26 +2371,6 @@ bool FlowGraphOptimizer::TryInlineFloat32x4Method(
ReplaceCall(call, minmax);
return true;
}
- case MethodRecognizer::kFloat32x4WithZWInXY:
- case MethodRecognizer::kFloat32x4InterleaveXY:
- case MethodRecognizer::kFloat32x4InterleaveZW:
- case MethodRecognizer::kFloat32x4InterleaveXYPairs:
- case MethodRecognizer::kFloat32x4InterleaveZWPairs: {
- Definition* left = call->ArgumentAt(0);
- Definition* right = call->ArgumentAt(1);
- // Type check left.
- AddCheckClass(left,
- ICData::ZoneHandle(
- call->ic_data()->AsUnaryClassChecksForArgNr(0)),
- call->deopt_id(),
- call->env(),
- call);
- Float32x4TwoArgShuffleInstr* two_arg_shuffle =
- new Float32x4TwoArgShuffleInstr(recognized_kind, new Value(left),
- new Value(right), call->deopt_id());
- ReplaceCall(call, two_arg_shuffle);
- return true;
- }
case MethodRecognizer::kFloat32x4Scale: {
Definition* left = call->ArgumentAt(0);
Definition* right = call->ArgumentAt(1);
@@ -2415,6 +2460,7 @@ bool FlowGraphOptimizer::TryInlineFloat32x4Method(
ReplaceCall(call, clamp);
return true;
}
+ case MethodRecognizer::kFloat32x4ShuffleMix:
case MethodRecognizer::kFloat32x4Shuffle: {
return InlineFloat32x4Getter(call, recognized_kind);
}
@@ -2432,6 +2478,8 @@ bool FlowGraphOptimizer::TryInlineUint32x4Method(
}
ASSERT(call->HasICData());
switch (recognized_kind) {
+ case MethodRecognizer::kUint32x4ShuffleMix:
+ case MethodRecognizer::kUint32x4Shuffle:
case MethodRecognizer::kUint32x4GetFlagX:
case MethodRecognizer::kUint32x4GetFlagY:
case MethodRecognizer::kUint32x4GetFlagZ:
@@ -6834,7 +6882,13 @@ void ConstantPropagator::VisitFloat32x4Constructor(
}
-void ConstantPropagator::VisitFloat32x4Shuffle(Float32x4ShuffleInstr* instr) {
+void ConstantPropagator::VisitSimd32x4Shuffle(Simd32x4ShuffleInstr* instr) {
+ SetValue(instr, non_constant_);
+}
+
+
+void ConstantPropagator::VisitSimd32x4ShuffleMix(
+ Simd32x4ShuffleMixInstr* instr) {
SetValue(instr, non_constant_);
}
@@ -6897,12 +6951,6 @@ void ConstantPropagator::VisitFloat32x4ToUint32x4(
}
-void ConstantPropagator::VisitFloat32x4TwoArgShuffle(
- Float32x4TwoArgShuffleInstr* instr) {
- SetValue(instr, non_constant_);
-}
-
-
void ConstantPropagator::VisitUint32x4BoolConstructor(
Uint32x4BoolConstructorInstr* instr) {
SetValue(instr, non_constant_);

Powered by Google App Engine
This is Rietveld 408576698