Open sherhut opened 5 years ago
I'll be happy to take this. @River707 @joker-eph Could you please assign to me?
Why would we even need to worry about loops that would never execute? Shouldn't these just be DCE'd?
Why would we even need to worry about loops that would never execute? Shouldn't these just be DCE'd?
Because: 1) at compile time, it may not be known whether they execute at least once; 2) at the time LICM is run, it may not be known whether they execute at least once, i.e., the fact that they are dead may arise only after further transformations.
As such, we can't hoist unless the lower bound on the trip count is known to be at least one.
Yep, thanks. I was thinking of something completely different.
On Thu, Oct 17, 2019 at 8:47 PM Uday Bondhugula notifications@github.com wrote:
Why would we even need to worry about loops that would never execute? Shouldn't these just be DCE'd?
Because:
- at compile time, it may not be known whether they execute at least once;
- at the time LICM is run, it may not be known whether they execute at least once, i.e., the fact that they are dead may arise only after further transformations.
As such, we can't hoist unless the lower bound on the trip count is known to be at least one.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/tensorflow/mlir/issues/194?email_source=notifications&email_token=AG37JDLT6FTQZWUZ5XETDTDQPEWVBA5CNFSM4JB2CF62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBSN43Y#issuecomment-543481455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG37JDLEFGERJTAGIRRIBTTQPEWVBANCNFSM4JB2CF6Q .
The current loop-invariant code motion pass does not consider trip counts when optimizing loops. This should be added to avoid hoisting code out of loops that actually never execute and hence adding additional computation.
The loop-like interface should probably grow a method to query whether a loop has a statically known trip count. For AffineFor, this can be answered using the mlir::getConstantTripCount(AffineForOp forOp) helper.