Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Nov 3, 2025

We cannot infer a struct is only created in a global, but we can see
global.gets and optimize them, at least, in a non-type-based way,
even in open world.

Fixes #8016


;; Non-type-based optimizations in --gsi
;; RUN: foreach %s %t wasm-opt --gsi -all -S -o - | filecheck %s
;; RUN: foreach %s %t wasm-opt --gsi --closed-world -all -S -o - | filecheck %s --check-prefix=CLOSD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all the output the same? If so, we don't need a new prefix here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, thanks. Removed.

}
addIfNoDWARFIssues("gsi");
}
addIfNoDWARFIssues("gsi");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbc: Will this also be enabled in -Os (from the options.optimizeLevel >= 2) condition on line 749 it seems this is for -O2 and -O3)?

At least the part of gsi that will preform this global.get + struct.get optimization will lead to lower code size and would therefore make sense to run in -Os.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this runs in -Os. -Os is equivalent to -O2 plus setting the shrink level to 1,

static constexpr const int OS_OPTIMIZE_LEVEL = 2;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open-world store-to-load forward optimization for globals

3 participants