Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
comment
  • Loading branch information
kripken committed Apr 11, 2024
commit f6331238620bcc9bbe3b0d7f548ea27e07fec771
18 changes: 15 additions & 3 deletions src/passes/OptimizeInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2068,9 +2068,21 @@ struct OptimizeInstructions
}

// They are all equal to each other, but not to the default value. If there
// are 2 or more elements here then we can save by using array.new (with 1,
// ArrayNewFixed is actually more compact, and we optimize ArrayNew to it,
// above).
// are 2 or more elements here then we can save by using array.new. For
// example, with 2 elements we are doing this:
//
// (array.new_fixed
// (A)
// (A)
// )
// =>
// (array.new
// (A)
// (i32.const 2) ;; get two copies of (A)
// )
//
// However, with 1, ArrayNewFixed is actually more compact, and we optimize
// ArrayNew to it, above.
if (size == 1) {
return;
}
Expand Down