From 1d116a904a41f969b549cac33a4baaf5a123c3ec Mon Sep 17 00:00:00 2001 From: Artem Serov Date: Tue, 21 May 2024 14:28:56 +0100 Subject: [SVE] Fix a bug with vectorization external set. This patch fixes a bug when LoopOptimization::vector_external_set_ (contains vector instructions to be inserted outside of newly generated loops) was reset more than once during vectorization. Instead, it should only be reset when vectorization of the loop has finished. It also adds a regression test for the situation: a loop is vectorized in predicated mode and a disambiguation test and a back-up scalar loop are needed and inserted. Note: This bug only affected predicated vectorization (e.g. using Arm SVE) and didn't impact any production devices. Test: run with ART_FORCE_TRY_PREDICATED_SIMD=true and without Test: 623-checker-loop-regressions Test: ./art/test.py --host --optimizing --jit Test: ./art/test.py --target --optimizing --jit Change-Id: I19fabd4d7034e5aa6421df79b2519d8f7e6ef43a --- compiler/optimizing/loop_optimization.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/optimizing/loop_optimization.h') diff --git a/compiler/optimizing/loop_optimization.h b/compiler/optimizing/loop_optimization.h index 4817060dfa..b6998c7f90 100644 --- a/compiler/optimizing/loop_optimization.h +++ b/compiler/optimizing/loop_optimization.h @@ -480,6 +480,7 @@ class HLoopOptimization : public HOptimization { bool CanRemoveCycle(); // Whether the current 'iset_' is removable. bool IsInPredicatedVectorizationMode() const { return predicated_vectorization_mode_; } + void MaybeInsertInVectorExternalSet(HInstruction* instruction); // Compiler options (to query ISA features). const CompilerOptions* compiler_options_; @@ -547,6 +548,12 @@ class HLoopOptimization : public HOptimization { // Tracks vector operations that are inserted outside of the loop (preheader, exit) // as part of vectorization (e.g. replicate scalar for loop invariants and reduce ops // for loop reductions). + // + // The instructions in the set are live for the whole vectorization process of the current + // loop, not just during generation of a particular loop version (as the sets above). + // + // Currently the set is being only used in the predicated mode - for assigning governing + // predicates. ScopedArenaSet* vector_external_set_; // A mapping between a basic block of the original loop and its associated PredicateInfo. -- cgit v1.2.3-59-g8ed1b