This patch adds a basic support for freeze instruction to JumpThreading
by making ComputeValueKnownInPredecessorsImpl look into its operand.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
180 ms | linux > Polly.ScopInfo::Unknown Unit Message ("") |
Event Timeline
Just as a side note, you may want to add freeze support to foldOpIntoPhi() in InstCombine, which I believe will also catch the two cases being tested here.
llvm/test/Transforms/JumpThreading/freeze.ll | ||
---|---|---|
30 | We should also have a negative test, say for undef as phi operand. |
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
708 | You can probably write this loop a bit more elegantly using something along these lines: erase_if(Result, [](std::pair<Constant *, BasicBlock *> &Pair) { return !isGuaranteedNotToBeUndefOrPoison(Pair.first); }); |
erase_if seems great.
In the test, freeze undef can be folded into something. Maybe GetBestDestForJumpOnUndef can be used. I'll make this as a follow-up patch.
LGTM. I'm not particularly familiar with JumpThreading though, so please wait a day in case there are more comments.
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
698 | Do we want to handle a freeze of a cast, or vice versa? |
llvm/lib/Transforms/Scalar/JumpThreading.cpp | ||
---|---|---|
698 | Yes, it sounds good. |
clang-format not found in user's PATH; not linting file.