[PATCH] Enable ExitValue rewrite only when expansion cost is low.
wmi at google.com
Thu May 28 10:44:30 PDT 2015
Hal and Andy, thanks for the helpful comments.
> Once LoopCanBeDel is false, it will never become true again. Please remove this variable and just 'return false' in all places where you set LoopCanBeDel to false.
> incoming -> Incoming
> Please update you patch for trunk. You probably don't need LastPN.
> IsLoopCanBeDel should be phrased "CanLoopBeDeleted". However, it's not just a query; it at least needs a very clear comment that it may hoist instructions into the preheader to facilitate the query.
I think it is fine to let later phase to do the LICM so I changed Loop::makeLoopInvariant to Loop::hasLoopInvariantOperands. CanLoopBeDeleted is a query only func now.
> As Hal pointed out, it's very important to return early from CanLoopBeDeleted. We should only scan all instructions in the loop if we know the loop can otherwise be deleted.
> I'm curious why you needed to enable aggressive exit value replacement in four unit tests. Can your logic determine that the loops can be deleted in those cases?
I changed the tests. Now aggressive exit value replacement is only enabled in test/Transforms/IndVarSimplify/lcssa-preservation.ll. That test is used to check IndVars preserves LCSSA form. I preserve the original test behavior by enabling aggressive exit value replacement. For other three tests, loops can be deleted.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 13551 bytes
Desc: not available
More information about the llvm-commits