Add AVX support for packed add/sub instructions on x86
Test: ./test.py --host, test-art-host-gtest
Change-Id: I48d05e6f6befd54657d962119a543b27a8a51d71
Signed-off-by: Shalini Salomi Bodapati <shalini.salomi.bodapati@intel.com>
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index 6c76ab8..c6e7560 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -351,8 +351,11 @@
// Translates vector operation to reduction kind.
static HVecReduce::ReductionKind GetReductionKind(HVecOperation* reduction) {
- if (reduction->IsVecAdd() ||
+ if (reduction->IsVecAdd() ||
reduction->IsVecSub() ||
+ #if defined(ART_ENABLE_CODEGEN_x86) || defined(ART_ENABLE_CODEGEN_x86_64)
+ reduction->IsVecAvxSub() || reduction->IsVecAvxAdd() ||
+ #endif
reduction->IsVecSADAccumulate() ||
reduction->IsVecDotProd()) {
return HVecReduce::kSum;
@@ -1940,10 +1943,34 @@
new (global_allocator_) HVecCnv(global_allocator_, opa, type, vector_length_, dex_pc),
new (global_allocator_) HTypeConversion(org_type, opa, dex_pc));
case HInstruction::kAdd:
+ #if defined(ART_ENABLE_CODEGEN_x86) || defined(ART_ENABLE_CODEGEN_x86_64)
+ if ((compiler_options_->GetInstructionSet() == InstructionSet::kX86 ||
+ compiler_options_->GetInstructionSet() == InstructionSet::kX86_64) &&
+ compiler_options_->GetInstructionSetFeatures()->AsX86InstructionSetFeatures()
+ ->HasAVX2()) {
+ GENERATE_VEC(
+ new (global_allocator_) HVecAvxAdd(
+ global_allocator_, opa, opb, type, vector_length_, dex_pc),
+ new (global_allocator_) HAdd(org_type, opa, opb, dex_pc));
+ UNREACHABLE(); // GENERATE_VEC ends with a "break".
+ }
+ #endif
GENERATE_VEC(
new (global_allocator_) HVecAdd(global_allocator_, opa, opb, type, vector_length_, dex_pc),
new (global_allocator_) HAdd(org_type, opa, opb, dex_pc));
case HInstruction::kSub:
+ #if defined(ART_ENABLE_CODEGEN_x86) || defined(ART_ENABLE_CODEGEN_x86_64)
+ if ((compiler_options_->GetInstructionSet() == InstructionSet::kX86 ||
+ compiler_options_->GetInstructionSet() == InstructionSet::kX86_64) &&
+ compiler_options_->GetInstructionSetFeatures()->AsX86InstructionSetFeatures()
+ ->HasAVX2()) {
+ GENERATE_VEC(
+ new (global_allocator_) HVecAvxSub(
+ global_allocator_, opa, opb, type, vector_length_, dex_pc),
+ new (global_allocator_) HSub(org_type, opa, opb, dex_pc));
+ UNREACHABLE(); // GENERATE_VEC ends with a "break".
+ }
+ #endif
GENERATE_VEC(
new (global_allocator_) HVecSub(global_allocator_, opa, opb, type, vector_length_, dex_pc),
new (global_allocator_) HSub(org_type, opa, opb, dex_pc));