This patch makes JumpThreading's ProcessImpliedCondition deal with frozen
conditions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
1253 | Would it make sense to improve isImpliedCondition, instead of manipulating the result here? (I haven't looked at the other users of isImpliedCondition, but it seems like the sort of thing isImpliedCondition should handle.) |
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
1253 | Actually, I have to say that it's hard to answer; After isImpliedCondition says something about an expression having freeze, the freeze should be properly consumed. This is needed to prevent other analyses/optimizations from concluding different result from the expression. For example, let's consider this example: c = freeze undef if (c) { c2 = freeze undef print(c2) print(c2) // These two prints should show the same result } If two prints are optimized by different analyses/transformations, they may print inconsistent values, which should be avoided. Another issue was that, the semantics of existing analysis functions (computeKnownBits, isImpliedCondition, isTruePredicate, etc) isn't clear when undef/poison is involved. I mean, at least documentation-wise. I believe this is another big thing to be clarified in the future... maybe along with the semantics of attributes like nonnull/align/etc. |
LGTM
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
1226 | nit: "or a nondeterministic value" |
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
1253 | Maybe extra parameter for isImpliedCondition to peek thru freezeinst? |
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
1253 | I don't think that's a good idea: An important aspect here is that the freeze is one-use and is dropped as part of the transform. I don't think this can be incorporated into the isImpliedCondition() API in a way that makes sense. |
Make test show diff, add a description about why @and_noopt is not optimized yet, update comments in ProcessImpliedCondition
clang-format not found in user's PATH; not linting file.