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
Updates
  • Loading branch information
vouillon committed Apr 18, 2024
commit dc67f1afc4125821b0e6cf5c8d1c6c29f7f9338c
15 changes: 9 additions & 6 deletions src/passes/OptimizeCasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
// Note that right now, we only consider RefAs with op RefAsNonNull as a cast.
// RefAs with ExternInternalize and ExternExternalize are not considered casts
// when obtaining fallthroughs, and so are ignored.
//
// TODO: Look past individual basic blocks? This may be worth considering
// given the pattern of a cast appearing in an if condition that is
// then used in an if arm, for example, where simple dominance shows
// the cast can be reused.

#include "ir/effects.h"
#include "ir/linear-execution.h"
Expand Down Expand Up @@ -439,15 +444,13 @@ struct BestCastFinder : public LinearExecutionWalker<BestCastFinder> {
void handleRefinement(Expression* curr) {
auto* teeFallthrough = Properties::getFallthrough(
curr, options, *getModule(), Properties::FallthroughBehavior::NoTeeBrIf);
if (auto* set = teeFallthrough->dynCast<LocalSet>()) {
if (set->isTee()) {
updateBestCast(curr, set->index);
}
if (auto* tee = teeFallthrough->dynCast<LocalSet>()) {
updateBestCast(curr, tee->index);
}
auto* fallthrough = Properties::getFallthrough(curr, options, *getModule());
auto* fallthrough =
Properties::getFallthrough(teeFallthrough, options, *getModule());
if (auto* get = fallthrough->dynCast<LocalGet>()) {
updateBestCast(curr, get->index);
return;
}
}

Expand Down