Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
2196 | As mentioned in the earlier patch (D123748), the Depth should be limited here to prevent a compile-time explosion. If the phi has a large number of operands, this could consume a lot of time - O(Operands^Depth). The code that this patch is copying from was added with D88276, and there is more discussion about it there. I'm not sure why it is using std::max instead of just passing MaxAnalysisRecursionDepth - 1. If I'm seeing the tests in this patch correctly, we will not see a functional difference on either of those tests by limiting the recursion. The other non-obvious part of this patch is the setting of the context instruction; that is copied/derived from: All of this copying and mutation suggests that we really need to create a helper function, so the logic is consistent for phi analysis across these functions. If that isn't feasible, at least copy the code comments, so we don't have to dig all over the place to figure out why this code does what it does. :) |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
2196 | Passing MaxAnalysisRecursionDepth - 1 leads to incorrect behavior, as it defeats the purpose of limiting the depth of recursion. Every time the code execution calls the function on this line the same depth Passing MaxAnalysisRecursionDepth - 1 is passed in, so line 2065 will never be true, and the function never terminates due to depth exceeding limit. |
Why was D124890 pulled back into this patch? I still think it would be better to have 2 patches to reduce risk.
looks like all comments have been addressed. Wait a few days to commit. (also abandon the duplicate https://reviews.llvm.org/D126020)
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
2193 | Rather than requiring Q.IIQ.UseInstrInfo here, it would be better to use Q.IIQ.hasNoUnsignedWrap() etc in the function. Presence of nowrap flags is not required for all cases. |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
2057 | Hm, I think that for recurrences, this context instruction adjustment is not necessary. I believe the reason why we need it in general for phis is that we might follow a backedge, in which case we will be working with values from a previous loop iterations. This can't happen when we're looking at Start, because it must dominate the whole loop. | |
2089 | Similar to the nowrap cases above, can't this (and div) use OrZero || Q.IIQ.isExact(BO)? |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
2057 | I saw similar usage in computeKnownBitsFromOperator. at line 1464. The comment said
I am worry about some unusual cases such as the "Start" value is actually coming from a BB dominated by PHI's BB, and matchSimpleRecurrence is not strict on checking value domination, so I would be cautious here |
Hm, I think that for recurrences, this context instruction adjustment is not necessary. I believe the reason why we need it in general for phis is that we might follow a backedge, in which case we will be working with values from a previous loop iterations. This can't happen when we're looking at Start, because it must dominate the whole loop.