Minor cleanup of MIN/MAX code.
Rationale:
Share the type dispatching code better.
Bug: b/65164101
Test: test-art-host,target
Change-Id: Ib06c915d570fd0a53f7734cdb316d2d16310db74
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index b0ddd8e..04da898 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -5484,9 +5484,9 @@
}
}
-void InstructionCodeGeneratorARM64::GenerateMinMax(LocationSummary* locations,
- bool is_min,
- DataType::Type type) {
+void InstructionCodeGeneratorARM64::GenerateMinMaxInt(LocationSummary* locations,
+ bool is_min,
+ DataType::Type type) {
Location op1 = locations->InAt(0);
Location op2 = locations->InAt(1);
Location out = locations->Out();
@@ -5537,24 +5537,29 @@
}
}
+// TODO: integrate with HandleBinaryOp?
+void InstructionCodeGeneratorARM64::GenerateMinMax(HBinaryOperation* minmax, bool is_min) {
+ DataType::Type type = minmax->GetResultType();
+ switch (type) {
+ case DataType::Type::kInt32:
+ case DataType::Type::kInt64:
+ GenerateMinMaxInt(minmax->GetLocations(), is_min, type);
+ break;
+ case DataType::Type::kFloat32:
+ case DataType::Type::kFloat64:
+ GenerateMinMaxFP(minmax->GetLocations(), is_min, type);
+ break;
+ default:
+ LOG(FATAL) << "Unexpected type for HMinMax " << type;
+ }
+}
+
void LocationsBuilderARM64::VisitMin(HMin* min) {
CreateMinMaxLocations(GetGraph()->GetAllocator(), min);
}
-// TODO: integrate with HandleBinaryOp?
void InstructionCodeGeneratorARM64::VisitMin(HMin* min) {
- switch (min->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(min->GetLocations(), /*is_min*/ true, min->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(min->GetLocations(), /*is_min*/ true, min->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMin " << min->GetResultType();
- }
+ GenerateMinMax(min, /*is_min*/ true);
}
void LocationsBuilderARM64::VisitMax(HMax* max) {
@@ -5562,18 +5567,7 @@
}
void InstructionCodeGeneratorARM64::VisitMax(HMax* max) {
- switch (max->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(max->GetLocations(), /*is_min*/ false, max->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(max->GetLocations(), /*is_min*/ false, max->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMax " << max->GetResultType();
- }
+ GenerateMinMax(max, /*is_min*/ false);
}
void LocationsBuilderARM64::VisitAbs(HAbs* abs) {
diff --git a/compiler/optimizing/code_generator_arm64.h b/compiler/optimizing/code_generator_arm64.h
index 70f5500..06cd540 100644
--- a/compiler/optimizing/code_generator_arm64.h
+++ b/compiler/optimizing/code_generator_arm64.h
@@ -273,8 +273,9 @@
void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
void HandleCondition(HCondition* instruction);
- void GenerateMinMax(LocationSummary* locations, bool is_min, DataType::Type type);
+ void GenerateMinMaxInt(LocationSummary* locations, bool is_min, DataType::Type type);
void GenerateMinMaxFP(LocationSummary* locations, bool is_min, DataType::Type type);
+ void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
// Generate a heap reference load using one register `out`:
//
diff --git a/compiler/optimizing/code_generator_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc
index 4fef027..8222fc0 100644
--- a/compiler/optimizing/code_generator_arm_vixl.cc
+++ b/compiler/optimizing/code_generator_arm_vixl.cc
@@ -4719,7 +4719,7 @@
}
}
-void InstructionCodeGeneratorARMVIXL::GenerateMinMax(LocationSummary* locations, bool is_min) {
+void InstructionCodeGeneratorARMVIXL::GenerateMinMaxInt(LocationSummary* locations, bool is_min) {
Location op1_loc = locations->InAt(0);
Location op2_loc = locations->InAt(1);
Location out_loc = locations->Out();
@@ -4780,8 +4780,8 @@
}
}
-void InstructionCodeGeneratorARMVIXL::GenerateMinMaxFloat(HInstruction* min_max, bool is_min) {
- LocationSummary* locations = min_max->GetLocations();
+void InstructionCodeGeneratorARMVIXL::GenerateMinMaxFloat(HInstruction* minmax, bool is_min) {
+ LocationSummary* locations = minmax->GetLocations();
Location op1_loc = locations->InAt(0);
Location op2_loc = locations->InAt(1);
Location out_loc = locations->Out();
@@ -4800,7 +4800,7 @@
const vixl32::Register temp1 = temps.Acquire();
vixl32::Register temp2 = RegisterFrom(locations->GetTemp(0));
vixl32::Label nan, done;
- vixl32::Label* final_label = codegen_->GetFinalLabel(min_max, &done);
+ vixl32::Label* final_label = codegen_->GetFinalLabel(minmax, &done);
DCHECK(op1.Is(out));
@@ -4841,8 +4841,8 @@
}
}
-void InstructionCodeGeneratorARMVIXL::GenerateMinMaxDouble(HInstruction* min_max, bool is_min) {
- LocationSummary* locations = min_max->GetLocations();
+void InstructionCodeGeneratorARMVIXL::GenerateMinMaxDouble(HInstruction* minmax, bool is_min) {
+ LocationSummary* locations = minmax->GetLocations();
Location op1_loc = locations->InAt(0);
Location op2_loc = locations->InAt(1);
Location out_loc = locations->Out();
@@ -4857,7 +4857,7 @@
vixl32::DRegister op2 = DRegisterFrom(op2_loc);
vixl32::DRegister out = DRegisterFrom(out_loc);
vixl32::Label handle_nan_eq, done;
- vixl32::Label* final_label = codegen_->GetFinalLabel(min_max, &done);
+ vixl32::Label* final_label = codegen_->GetFinalLabel(minmax, &done);
DCHECK(op1.Is(out));
@@ -4892,27 +4892,32 @@
}
}
+void InstructionCodeGeneratorARMVIXL::GenerateMinMax(HBinaryOperation* minmax, bool is_min) {
+ DataType::Type type = minmax->GetResultType();
+ switch (type) {
+ case DataType::Type::kInt32:
+ GenerateMinMaxInt(minmax->GetLocations(), is_min);
+ break;
+ case DataType::Type::kInt64:
+ GenerateMinMaxLong(minmax->GetLocations(), is_min);
+ break;
+ case DataType::Type::kFloat32:
+ GenerateMinMaxFloat(minmax, is_min);
+ break;
+ case DataType::Type::kFloat64:
+ GenerateMinMaxDouble(minmax, is_min);
+ break;
+ default:
+ LOG(FATAL) << "Unexpected type for HMinMax " << type;
+ }
+}
+
void LocationsBuilderARMVIXL::VisitMin(HMin* min) {
CreateMinMaxLocations(GetGraph()->GetAllocator(), min);
}
void InstructionCodeGeneratorARMVIXL::VisitMin(HMin* min) {
- switch (min->GetResultType()) {
- case DataType::Type::kInt32:
- GenerateMinMax(min->GetLocations(), /*is_min*/ true);
- break;
- case DataType::Type::kInt64:
- GenerateMinMaxLong(min->GetLocations(), /*is_min*/ true);
- break;
- case DataType::Type::kFloat32:
- GenerateMinMaxFloat(min, /*is_min*/ true);
- break;
- case DataType::Type::kFloat64:
- GenerateMinMaxDouble(min, /*is_min*/ true);
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMin " << min->GetResultType();
- }
+ GenerateMinMax(min, /*is_min*/ true);
}
void LocationsBuilderARMVIXL::VisitMax(HMax* max) {
@@ -4920,22 +4925,7 @@
}
void InstructionCodeGeneratorARMVIXL::VisitMax(HMax* max) {
- switch (max->GetResultType()) {
- case DataType::Type::kInt32:
- GenerateMinMax(max->GetLocations(), /*is_min*/ false);
- break;
- case DataType::Type::kInt64:
- GenerateMinMaxLong(max->GetLocations(), /*is_min*/ false);
- break;
- case DataType::Type::kFloat32:
- GenerateMinMaxFloat(max, /*is_min*/ false);
- break;
- case DataType::Type::kFloat64:
- GenerateMinMaxDouble(max, /*is_min*/ false);
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMax " << max->GetResultType();
- }
+ GenerateMinMax(max, /*is_min*/ false);
}
void LocationsBuilderARMVIXL::VisitAbs(HAbs* abs) {
diff --git a/compiler/optimizing/code_generator_arm_vixl.h b/compiler/optimizing/code_generator_arm_vixl.h
index 726a2f9..8e6bc06 100644
--- a/compiler/optimizing/code_generator_arm_vixl.h
+++ b/compiler/optimizing/code_generator_arm_vixl.h
@@ -349,10 +349,11 @@
bool value_can_be_null);
void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
- void GenerateMinMax(LocationSummary* locations, bool is_min);
+ void GenerateMinMaxInt(LocationSummary* locations, bool is_min);
void GenerateMinMaxLong(LocationSummary* locations, bool is_min);
- void GenerateMinMaxFloat(HInstruction* min_max, bool is_min);
- void GenerateMinMaxDouble(HInstruction* min_max, bool is_min);
+ void GenerateMinMaxFloat(HInstruction* minmax, bool is_min);
+ void GenerateMinMaxDouble(HInstruction* minmax, bool is_min);
+ void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
// Generate a heap reference load using one register `out`:
//
diff --git a/compiler/optimizing/code_generator_mips.cc b/compiler/optimizing/code_generator_mips.cc
index ae42bbc..825b237 100644
--- a/compiler/optimizing/code_generator_mips.cc
+++ b/compiler/optimizing/code_generator_mips.cc
@@ -8799,10 +8799,10 @@
}
}
-void InstructionCodeGeneratorMIPS::GenerateMinMax(LocationSummary* locations,
- bool is_min,
- bool isR6,
- DataType::Type type) {
+void InstructionCodeGeneratorMIPS::GenerateMinMaxInt(LocationSummary* locations,
+ bool is_min,
+ bool isR6,
+ DataType::Type type) {
if (isR6) {
// Some architectures, such as ARM and MIPS (prior to r6), have a
// conditional move instruction which only changes the target
@@ -9130,24 +9130,29 @@
}
}
+void InstructionCodeGeneratorMIPS::GenerateMinMax(HBinaryOperation* minmax, bool is_min) {
+ bool isR6 = codegen_->GetInstructionSetFeatures().IsR6();
+ DataType::Type type = minmax->GetResultType();
+ switch (type) {
+ case DataType::Type::kInt32:
+ case DataType::Type::kInt64:
+ GenerateMinMaxInt(minmax->GetLocations(), is_min, isR6, type);
+ break;
+ case DataType::Type::kFloat32:
+ case DataType::Type::kFloat64:
+ GenerateMinMaxFP(minmax->GetLocations(), is_min, isR6, type);
+ break;
+ default:
+ LOG(FATAL) << "Unexpected type for HMinMax " << type;
+ }
+}
+
void LocationsBuilderMIPS::VisitMin(HMin* min) {
CreateMinMaxLocations(GetGraph()->GetAllocator(), min);
}
void InstructionCodeGeneratorMIPS::VisitMin(HMin* min) {
- bool isR6 = codegen_->GetInstructionSetFeatures().IsR6();
- switch (min->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(min->GetLocations(), /*is_min*/ true, isR6, min->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(min->GetLocations(), /*is_min*/ true, isR6, min->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMin " << min->GetResultType();
- }
+ GenerateMinMax(min, /*is_min*/ true);
}
void LocationsBuilderMIPS::VisitMax(HMax* max) {
@@ -9155,19 +9160,7 @@
}
void InstructionCodeGeneratorMIPS::VisitMax(HMax* max) {
- bool isR6 = codegen_->GetInstructionSetFeatures().IsR6();
- switch (max->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(max->GetLocations(), /*is_min*/ false, isR6, max->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(max->GetLocations(), /*is_min*/ false, isR6, max->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMax " << max->GetResultType();
- }
+ GenerateMinMax(max, /*is_min*/ false);
}
void LocationsBuilderMIPS::VisitAbs(HAbs* abs) {
diff --git a/compiler/optimizing/code_generator_mips.h b/compiler/optimizing/code_generator_mips.h
index ae5fe5b..b02a216 100644
--- a/compiler/optimizing/code_generator_mips.h
+++ b/compiler/optimizing/code_generator_mips.h
@@ -246,8 +246,9 @@
bool value_can_be_null);
void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info, uint32_t dex_pc);
- void GenerateMinMax(LocationSummary* locations, bool is_min, bool isR6, DataType::Type type);
+ void GenerateMinMaxInt(LocationSummary* locations, bool is_min, bool isR6, DataType::Type type);
void GenerateMinMaxFP(LocationSummary* locations, bool is_min, bool isR6, DataType::Type type);
+ void GenerateMinMax(HBinaryOperation*, bool is_min);
void GenerateAbsFP(LocationSummary* locations, DataType::Type type, bool isR2OrNewer, bool isR6);
// Generate a heap reference load using one register `out`:
diff --git a/compiler/optimizing/code_generator_mips64.cc b/compiler/optimizing/code_generator_mips64.cc
index 8031cca..9bb1bfb 100644
--- a/compiler/optimizing/code_generator_mips64.cc
+++ b/compiler/optimizing/code_generator_mips64.cc
@@ -6685,7 +6685,7 @@
}
}
-void InstructionCodeGeneratorMIPS64::GenerateMinMax(LocationSummary* locations, bool is_min) {
+void InstructionCodeGeneratorMIPS64::GenerateMinMaxInt(LocationSummary* locations, bool is_min) {
GpuRegister lhs = locations->InAt(0).AsRegister<GpuRegister>();
GpuRegister rhs = locations->InAt(1).AsRegister<GpuRegister>();
GpuRegister out = locations->Out().AsRegister<GpuRegister>();
@@ -6809,23 +6809,28 @@
__ Bind(&done);
}
+void InstructionCodeGeneratorMIPS64::GenerateMinMax(HBinaryOperation* minmax, bool is_min) {
+ DataType::Type type = minmax->GetResultType();
+ switch (type) {
+ case DataType::Type::kInt32:
+ case DataType::Type::kInt64:
+ GenerateMinMaxInt(minmax->GetLocations(), is_min);
+ break;
+ case DataType::Type::kFloat32:
+ case DataType::Type::kFloat64:
+ GenerateMinMaxFP(minmax->GetLocations(), is_min, type);
+ break;
+ default:
+ LOG(FATAL) << "Unexpected type for HMinMax " << type;
+ }
+}
+
void LocationsBuilderMIPS64::VisitMin(HMin* min) {
CreateMinMaxLocations(GetGraph()->GetAllocator(), min);
}
void InstructionCodeGeneratorMIPS64::VisitMin(HMin* min) {
- switch (min->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(min->GetLocations(), /*is_min*/ true);
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(min->GetLocations(), /*is_min*/ true, min->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMin " << min->GetResultType();
- }
+ GenerateMinMax(min, /*is_min*/ true);
}
void LocationsBuilderMIPS64::VisitMax(HMax* max) {
@@ -6833,18 +6838,7 @@
}
void InstructionCodeGeneratorMIPS64::VisitMax(HMax* max) {
- switch (max->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(max->GetLocations(), /*is_min*/ false);
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(max->GetLocations(), /*is_min*/ false, max->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMax " << max->GetResultType();
- }
+ GenerateMinMax(max, /*is_min*/ false);
}
void LocationsBuilderMIPS64::VisitAbs(HAbs* abs) {
diff --git a/compiler/optimizing/code_generator_mips64.h b/compiler/optimizing/code_generator_mips64.h
index 5d925d5..ef4386b 100644
--- a/compiler/optimizing/code_generator_mips64.h
+++ b/compiler/optimizing/code_generator_mips64.h
@@ -242,8 +242,9 @@
bool value_can_be_null);
void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
- void GenerateMinMax(LocationSummary* locations, bool is_min);
+ void GenerateMinMaxInt(LocationSummary* locations, bool is_min);
void GenerateMinMaxFP(LocationSummary* locations, bool is_min, DataType::Type type);
+ void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
// Generate a heap reference load using one register `out`:
//
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index 536909a..c887d9e 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -3836,9 +3836,9 @@
}
}
-void InstructionCodeGeneratorX86::GenerateMinMax(LocationSummary* locations,
- bool is_min,
- DataType::Type type) {
+void InstructionCodeGeneratorX86::GenerateMinMaxInt(LocationSummary* locations,
+ bool is_min,
+ DataType::Type type) {
Location op1_loc = locations->InAt(0);
Location op2_loc = locations->InAt(1);
@@ -3978,23 +3978,28 @@
__ Bind(&done);
}
+void InstructionCodeGeneratorX86::GenerateMinMax(HBinaryOperation* minmax, bool is_min) {
+ DataType::Type type = minmax->GetResultType();
+ switch (type) {
+ case DataType::Type::kInt32:
+ case DataType::Type::kInt64:
+ GenerateMinMaxInt(minmax->GetLocations(), is_min, type);
+ break;
+ case DataType::Type::kFloat32:
+ case DataType::Type::kFloat64:
+ GenerateMinMaxFP(minmax->GetLocations(), is_min, type);
+ break;
+ default:
+ LOG(FATAL) << "Unexpected type for HMinMax " << type;
+ }
+}
+
void LocationsBuilderX86::VisitMin(HMin* min) {
CreateMinMaxLocations(GetGraph()->GetAllocator(), min);
}
void InstructionCodeGeneratorX86::VisitMin(HMin* min) {
- switch (min->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(min->GetLocations(), /*is_min*/ true, min->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(min->GetLocations(), /*is_min*/ true, min->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMin " << min->GetResultType();
- }
+ GenerateMinMax(min, /*is_min*/ true);
}
void LocationsBuilderX86::VisitMax(HMax* max) {
@@ -4002,18 +4007,7 @@
}
void InstructionCodeGeneratorX86::VisitMax(HMax* max) {
- switch (max->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(max->GetLocations(), /*is_min*/ false, max->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(max->GetLocations(), /*is_min*/ false, max->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMax " << max->GetResultType();
- }
+ GenerateMinMax(max, /*is_min*/ false);
}
void LocationsBuilderX86::VisitAbs(HAbs* abs) {
diff --git a/compiler/optimizing/code_generator_x86.h b/compiler/optimizing/code_generator_x86.h
index 82496d1..d5abf2a 100644
--- a/compiler/optimizing/code_generator_x86.h
+++ b/compiler/optimizing/code_generator_x86.h
@@ -225,8 +225,9 @@
void GenerateShlLong(const Location& loc, int shift);
void GenerateShrLong(const Location& loc, int shift);
void GenerateUShrLong(const Location& loc, int shift);
- void GenerateMinMax(LocationSummary* locations, bool is_min, DataType::Type type);
+ void GenerateMinMaxInt(LocationSummary* locations, bool is_min, DataType::Type type);
void GenerateMinMaxFP(LocationSummary* locations, bool is_min, DataType::Type type);
+ void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
void HandleFieldSet(HInstruction* instruction,
const FieldInfo& field_info,
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index bb1fbc5..d42990d 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -3843,9 +3843,9 @@
}
}
-void InstructionCodeGeneratorX86_64::GenerateMinMax(LocationSummary* locations,
- bool is_min,
- DataType::Type type) {
+void InstructionCodeGeneratorX86_64::GenerateMinMaxInt(LocationSummary* locations,
+ bool is_min,
+ DataType::Type type) {
Location op1_loc = locations->InAt(0);
Location op2_loc = locations->InAt(1);
@@ -3960,23 +3960,28 @@
__ Bind(&done);
}
+void InstructionCodeGeneratorX86_64::GenerateMinMax(HBinaryOperation* minmax, bool is_min) {
+ DataType::Type type = minmax->GetResultType();
+ switch (type) {
+ case DataType::Type::kInt32:
+ case DataType::Type::kInt64:
+ GenerateMinMaxInt(minmax->GetLocations(), is_min, type);
+ break;
+ case DataType::Type::kFloat32:
+ case DataType::Type::kFloat64:
+ GenerateMinMaxFP(minmax->GetLocations(), is_min, type);
+ break;
+ default:
+ LOG(FATAL) << "Unexpected type for HMinMax " << type;
+ }
+}
+
void LocationsBuilderX86_64::VisitMin(HMin* min) {
CreateMinMaxLocations(GetGraph()->GetAllocator(), min);
}
void InstructionCodeGeneratorX86_64::VisitMin(HMin* min) {
- switch (min->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(min->GetLocations(), /*is_min*/ true, min->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(min->GetLocations(), /*is_min*/ true, min->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMin " << min->GetResultType();
- }
+ GenerateMinMax(min, /*is_min*/ true);
}
void LocationsBuilderX86_64::VisitMax(HMax* max) {
@@ -3984,18 +3989,7 @@
}
void InstructionCodeGeneratorX86_64::VisitMax(HMax* max) {
- switch (max->GetResultType()) {
- case DataType::Type::kInt32:
- case DataType::Type::kInt64:
- GenerateMinMax(max->GetLocations(), /*is_min*/ false, max->GetResultType());
- break;
- case DataType::Type::kFloat32:
- case DataType::Type::kFloat64:
- GenerateMinMaxFP(max->GetLocations(), /*is_min*/ false, max->GetResultType());
- break;
- default:
- LOG(FATAL) << "Unexpected type for HMax " << max->GetResultType();
- }
+ GenerateMinMax(max, /*is_min*/ false);
}
void LocationsBuilderX86_64::VisitAbs(HAbs* abs) {
diff --git a/compiler/optimizing/code_generator_x86_64.h b/compiler/optimizing/code_generator_x86_64.h
index 933afda..7fc36a9 100644
--- a/compiler/optimizing/code_generator_x86_64.h
+++ b/compiler/optimizing/code_generator_x86_64.h
@@ -222,8 +222,9 @@
bool value_can_be_null);
void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
- void GenerateMinMax(LocationSummary* locations, bool is_min, DataType::Type type);
+ void GenerateMinMaxInt(LocationSummary* locations, bool is_min, DataType::Type type);
void GenerateMinMaxFP(LocationSummary* locations, bool is_min, DataType::Type type);
+ void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
// Generate a heap reference load using one register `out`:
//