Commit c1287aeb authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[wasm] Do not unroll unreachable loops

Bug: v8:11298, v8:13292
Change-Id: Ifabcbb64889012778439fb14e22a7cf885965b1e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905724
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83363}
parent b588a3c6
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "src/codegen/reloc-info.h" #include "src/codegen/reloc-info.h"
#include "src/common/high-allocation-throughput-scope.h" #include "src/common/high-allocation-throughput-scope.h"
#include "src/compiler/add-type-assertions-reducer.h" #include "src/compiler/add-type-assertions-reducer.h"
#include "src/compiler/all-nodes.h"
#include "src/compiler/backend/code-generator.h" #include "src/compiler/backend/code-generator.h"
#include "src/compiler/backend/frame-elider.h" #include "src/compiler/backend/frame-elider.h"
#include "src/compiler/backend/instruction-selector.h" #include "src/compiler/backend/instruction-selector.h"
...@@ -1699,19 +1700,21 @@ struct WasmLoopUnrollingPhase { ...@@ -1699,19 +1700,21 @@ struct WasmLoopUnrollingPhase {
void Run(PipelineData* data, Zone* temp_zone, void Run(PipelineData* data, Zone* temp_zone,
std::vector<compiler::WasmLoopInfo>* loop_infos) { std::vector<compiler::WasmLoopInfo>* loop_infos) {
if (loop_infos->empty()) return;
AllNodes all_nodes(temp_zone, data->graph(), data->graph()->end());
for (WasmLoopInfo& loop_info : *loop_infos) { for (WasmLoopInfo& loop_info : *loop_infos) {
if (loop_info.can_be_innermost) { if (!loop_info.can_be_innermost) continue;
ZoneUnorderedSet<Node*>* loop = if (!all_nodes.IsReachable(loop_info.header)) continue;
LoopFinder::FindSmallInnermostLoopFromHeader( ZoneUnorderedSet<Node*>* loop =
loop_info.header, temp_zone, LoopFinder::FindSmallInnermostLoopFromHeader(
// Only discover the loop until its size is the maximum unrolled loop_info.header, temp_zone,
// size for its depth. // Only discover the loop until its size is the maximum unrolled
maximum_unrollable_size(loop_info.nesting_depth), true); // size for its depth.
if (loop == nullptr) continue; maximum_unrollable_size(loop_info.nesting_depth), true);
UnrollLoop(loop_info.header, loop, loop_info.nesting_depth, if (loop == nullptr) continue;
data->graph(), data->common(), temp_zone, UnrollLoop(loop_info.header, loop, loop_info.nesting_depth, data->graph(),
data->source_positions(), data->node_origins()); data->common(), temp_zone, data->source_positions(),
} data->node_origins());
} }
EliminateLoopExits(loop_infos); EliminateLoopExits(loop_infos);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment