If a PHI node has multiple (identical) values for a given block, rewriteLoopExitValues must either rewrite all of them or none of them. Therefore, instead of tracking the cost for the individual values, track the cost per unique BB.
See PR45835
Differential D79720
[IndVarSimplify][LoopUtils] Track rewrite cost per unique BB (PR45835) dmajor on May 11 2020, 9:14 AM. Authored by
Details
If a PHI node has multiple (identical) values for a given block, rewriteLoopExitValues must either rewrite all of them or none of them. Therefore, instead of tracking the cost for the individual values, track the cost per unique BB. See PR45835
Diff Detail Event TimelineComment Actions Note: the test case does not currently fail on trunk before this change (although it does fail on the 10.0 release branch, where I would eventually like to get this merged) because after D73744 it is no longer blanket assumed that SCEVMinMaxExpr is high cost. Any pointers on how I could modify the test to get around that? (I'm not familiar with why this IR is considered to have a SCEVMinMaxExpr or what it would take to make it high cost.) Comment Actions Thank you for looking into it! (In reply to dmajor from https://bugs.llvm.org/show_bug.cgi?id=45835#c3)
Yes, but it is still not obvious to me as to why that happens?
Comment Actions If I'm understanding my recording correctly -- the reason the expansion was found the second time was that we expanded the value the first time, immediately after computing isHighCostExpansion: https://github.com/llvm/llvm-project/blob/release/10.x/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp#L675 Comment Actions But that doesn't make sense to me. Comment Actions As discussed in IRC, there is a much more fundamental problem that needs to be solved. |
clang-format: please reformat the code