// Copyright 2022 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/compiler/turboshaft/decompression-optimization.h" #include "src/codegen/machine-type.h" #include "src/compiler/turboshaft/copying-phase.h" #include "src/compiler/turboshaft/operations.h" #include "src/compiler/turboshaft/representations.h" namespace v8::internal::compiler::turboshaft { namespace { // Analyze the uses of values to determine if a compressed value has any uses // that need it to be decompressed. Since this analysis looks at uses, we // iterate the graph backwards, updating the analysis state for the inputs of an // operation. Due to loop phis, we need to compute a fixed-point. Therefore, we // re-visit the loop if a loop phi backedge changes something. As a performance // optimization, we keep track of operations (`candidates`) that need to be // updated potentially, so that we don't have to walk the whole graph again. struct DecompressionAnalyzer { … }; void DecompressionAnalyzer::ProcessOperation(const Operation& op) { … } // Checks if {base_idx} (which should be the base of a LoadOp) can be kept // compressed and decompressed using complex addressing mode. If not, marks it // as needing decompressiong. void DecompressionAnalyzer::MarkAddressingBase(OpIndex base_idx) { … } } // namespace // Instead of using `CopyingPhase`, we directly mutate the operations after // the analysis. Doing it in-place is possible because we only modify operation // options. void RunDecompressionOptimization(Graph& graph, Zone* phase_zone) { … } } // namespace v8::internal::compiler::turboshaft