diff options
| author | 2017-05-02 16:04:38 +0000 | |
|---|---|---|
| committer | 2017-05-02 16:04:39 +0000 | |
| commit | bf065261f65692a312439b453bdd328369793d69 (patch) | |
| tree | 1c83096a38d4d1ec749cac861e2326744d19b728 /compiler/optimizing/loop_optimization.cc | |
| parent | 874610010fc9f2191a55c281347995da0f43ce61 (diff) | |
| parent | 65ffd8ef044465c47d4f97ab2556310f9ee30a01 (diff) | |
Merge "Bug fix on shift that exceeds "lane width"."
Diffstat (limited to 'compiler/optimizing/loop_optimization.cc')
| -rw-r--r-- | compiler/optimizing/loop_optimization.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc index c783ddecf5..bbc55dd16f 100644 --- a/compiler/optimizing/loop_optimization.cc +++ b/compiler/optimizing/loop_optimization.cc @@ -833,17 +833,22 @@ bool HLoopOptimization::VectorizeUse(LoopNode* node, // TODO: accept symbolic, albeit loop invariant shift factors. HInstruction* opa = instruction->InputAt(0); HInstruction* opb = instruction->InputAt(1); - if (VectorizeUse(node, opa, generate_code, type, restrictions) && opb->IsIntConstant()) { - if (generate_code) { - // Make sure shift factor only looks at lower bits, as defined for sequential shifts. - // Note that even the narrower SIMD shifts do the right thing after that. - int32_t mask = (instruction->GetType() == Primitive::kPrimLong) - ? kMaxLongShiftDistance - : kMaxIntShiftDistance; - HInstruction* s = graph_->GetIntConstant(opb->AsIntConstant()->GetValue() & mask); - GenerateVecOp(instruction, vector_map_->Get(opa), s, type); + int64_t value = 0; + if (VectorizeUse(node, opa, generate_code, type, restrictions) && IsInt64AndGet(opb, &value)) { + // Make sure shift distance only looks at lower bits, as defined for sequential shifts. + int64_t mask = (instruction->GetType() == Primitive::kPrimLong) + ? kMaxLongShiftDistance + : kMaxIntShiftDistance; + int64_t distance = value & mask; + // Restrict shift distance to packed data type width. + int64_t max_distance = Primitive::ComponentSize(type) * 8; + if (0 <= distance && distance < max_distance) { + if (generate_code) { + HInstruction* s = graph_->GetIntConstant(distance); + GenerateVecOp(instruction, vector_map_->Get(opa), s, type); + } + return true; } - return true; } } else if (instruction->IsInvokeStaticOrDirect()) { // Accept particular intrinsics. |