From e42a58696059fd1cadcf25e10223b979214984b3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 18 May 2023 14:58:05 -0700 Subject: [PATCH] Improve TODO docs in OptimizeCasts (#5732) --- src/passes/OptimizeCasts.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/passes/OptimizeCasts.cpp b/src/passes/OptimizeCasts.cpp index 85411015772..8f13981bf2c 100644 --- a/src/passes/OptimizeCasts.cpp +++ b/src/passes/OptimizeCasts.cpp @@ -72,13 +72,23 @@ // sense in new pass anyhow, and things should be simpler overall to keep such // casts all in one pass, here. // -// TODO: Move casts earlier in a basic block as well, at least in traps-never- -// happen mode where we can assume they never fail. -// TODO: Look past individual basic blocks? -// TODO: Look at LocalSet as well and not just Get. That would add some overlap -// with the other passes mentioned above, but once we do things like -// moving casts earlier as in the other TODO, we'd be doing uniquely -// useful things with LocalSet here. +// TODO: 1. Move casts earlier in a basic block as well, at least in +// traps-never-happen mode where we can assume they never fail, and +// perhaps in other situations too. +// TODO: 2. 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. +// TODO: 3. Look at LocalSet as well and not just Get. That would add some +// overlap with the other passes mentioned above (SimplifyLocals and +// RedundantSetElimination also track sets and can switch a get to use +// a better set's index when that refines the type). But once we do the +// first two TODOs above then we'd be adding some novel things here, +// as we could optimize "backwards" as well (TODO 1) and past basic +// blocks (TODO 2, though RedundantSetElimination does that as well). +// However, we should consider whether improving those other passes +// might make more sense (as it would help more than casts, if we could +// make them operate "backwards" and/or past basic blocks). // #include "ir/linear-execution.h"