summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_unit_test.h
diff options
context:
space:
mode:
author Chris Jones <christopher.jones@arm.com> 2024-06-03 16:25:38 +0100
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-11-06 10:48:31 +0000
commit740ae3479b54495d2dda92a000107325b08faf35 (patch)
tree66db8e0034b1d901988d2b4c67371f238bad88b7 /compiler/optimizing/optimizing_unit_test.h
parent8cec104ae64bd45e1377d799ac4653fbce7fb631 (diff)
Support all conditions in predicated vectorization
Support all condition types inside the condition when performing diamond loop auto-vectorization. This allows diamond loop auto-vectorization to be performed on a greater variety of loops. To support this change, new vector condition nodes are added to mirror the scalar condition nodes. Also add a new gtest class to test whether predicated vectorization can be performed on different combinations of condition types and data types. Authors: Chris Jones <christopher.jones@arm.com>, Konstantin Baladurin <konstantin.baladurin@arm.com> Test: export ART_FORCE_TRY_PREDICATED_SIMD=true && \ art/test.py --target --optimizing Test: art/test.py --target --host --optimizing Test: 661-checker-simd-cf-loops Test: art/test.py --gtest art_compiler_tests Change-Id: Ic9c925f1a58ada13d9031de3b445dcd4f77764b7
Diffstat (limited to 'compiler/optimizing/optimizing_unit_test.h')
-rw-r--r--compiler/optimizing/optimizing_unit_test.h71
1 files changed, 62 insertions, 9 deletions
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index e2f3e0a510..018ffce196 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -632,7 +632,7 @@ class OptimizingUnitTestHelper {
HInstruction* index,
HInstruction* value,
DataType::Type packed_type,
- size_t vector_size_in_bytes = kDefaultTestVectorSize,
+ size_t vector_size_in_bytes = kDefaultTestVectorSizeInBytes,
uint32_t dex_pc = kNoDexPc) {
size_t num_of_elements = GetNumberOfElementsInVector(vector_size_in_bytes, packed_type);
SideEffects side_effects = SideEffects::ArrayWriteOfType(packed_type);
@@ -642,12 +642,42 @@ class OptimizingUnitTestHelper {
return vec_store;
}
- HVecPredToBoolean* MakeVecPredToBoolean(HBasicBlock* block,
- HInstruction* input,
- HVecPredToBoolean::PCondKind pred_cond,
- DataType::Type packed_type,
- size_t vector_size_in_bytes = kDefaultTestVectorSize,
- uint32_t dex_pc = kNoDexPc) {
+ HVecPredSetAll* MakeVecPredSetAll(HBasicBlock* block,
+ HInstruction* input,
+ DataType::Type packed_type,
+ size_t vector_size_in_bytes = kDefaultTestVectorSizeInBytes,
+ uint32_t dex_pc = kNoDexPc) {
+ size_t num_of_elements = GetNumberOfElementsInVector(vector_size_in_bytes, packed_type);
+ HVecPredSetAll* predicate = new (GetAllocator()) HVecPredSetAll(
+ GetAllocator(), input, packed_type, num_of_elements, dex_pc);
+ AddOrInsertInstruction(block, predicate);
+ return predicate;
+ }
+
+ HVecReplicateScalar* MakeVecReplicateScalar(
+ HBasicBlock* block,
+ HInstruction* scalar,
+ DataType::Type packed_type,
+ size_t vector_size_in_bytes = kDefaultTestVectorSizeInBytes,
+ HVecPredSetOperation* predicate = nullptr,
+ uint32_t dex_pc = kNoDexPc) {
+ size_t num_of_elements = GetNumberOfElementsInVector(vector_size_in_bytes, packed_type);
+ HVecReplicateScalar* vec_replicate_scalar = new (GetAllocator()) HVecReplicateScalar(
+ GetAllocator(), scalar, packed_type, num_of_elements, dex_pc);
+ AddOrInsertInstruction(block, vec_replicate_scalar);
+ if (predicate != nullptr) {
+ vec_replicate_scalar->SetMergingGoverningPredicate(predicate);
+ }
+ return vec_replicate_scalar;
+ }
+
+ HVecPredToBoolean* MakeVecPredToBoolean(
+ HBasicBlock* block,
+ HInstruction* input,
+ HVecPredToBoolean::PCondKind pred_cond,
+ DataType::Type packed_type,
+ size_t vector_size_in_bytes = kDefaultTestVectorSizeInBytes,
+ uint32_t dex_pc = kNoDexPc) {
size_t num_of_elements = GetNumberOfElementsInVector(vector_size_in_bytes, packed_type);
HVecPredToBoolean* vec_pred_to_boolean = new (GetAllocator()) HVecPredToBoolean(
GetAllocator(),
@@ -665,7 +695,7 @@ class OptimizingUnitTestHelper {
HInstruction* right,
HVecPredWhile::CondKind cond,
DataType::Type packed_type,
- size_t vector_size_in_bytes = kDefaultTestVectorSize,
+ size_t vector_size_in_bytes = kDefaultTestVectorSizeInBytes,
uint32_t dex_pc = kNoDexPc) {
size_t num_of_elements = GetNumberOfElementsInVector(vector_size_in_bytes, packed_type);
HVecPredWhile* vec_pred_while = new (GetAllocator()) HVecPredWhile(
@@ -732,6 +762,29 @@ class OptimizingUnitTestHelper {
return condition;
}
+ HVecCondition* MakeVecCondition(HBasicBlock* block,
+ IfCondition cond,
+ HInstruction* first,
+ HInstruction* second,
+ DataType::Type packed_type,
+ size_t vector_size_in_bytes = kDefaultTestVectorSizeInBytes,
+ HVecPredSetOperation* predicate = nullptr,
+ uint32_t dex_pc = kNoDexPc) {
+ size_t num_of_elements = GetNumberOfElementsInVector(vector_size_in_bytes, packed_type);
+ HVecCondition* condition = HVecCondition::Create(graph_,
+ cond,
+ first,
+ second,
+ packed_type,
+ num_of_elements,
+ dex_pc);
+ AddOrInsertInstruction(block, condition);
+ if (predicate != nullptr) {
+ condition->SetMergingGoverningPredicate(predicate);
+ }
+ return condition;
+ }
+
HSelect* MakeSelect(HBasicBlock* block,
HInstruction* condition,
HInstruction* true_value,
@@ -877,7 +930,7 @@ class OptimizingUnitTestHelper {
// The default size of vectors to use for tests, in bytes. 16 bytes (128 bits) is used as it is
// commonly the smallest size of vector used in vector extensions.
- static constexpr size_t kDefaultTestVectorSize = 16;
+ static constexpr size_t kDefaultTestVectorSizeInBytes = 16;
ScopedNullHandle<mirror::Class> null_klass_;
};