This patch adds folding freeze into phi if it has only one operand to target.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
130 ms | linux > Polly.ScopInfo::Unknown Unit Message ("") |
Event Timeline
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | ||
---|---|---|
1053 | Won't this let through something like a constant vector with one undef element? Maybe just use the usual guaranteed-not-undef query here? | |
llvm/test/Transforms/InstCombine/freeze-phi.ll | ||
216 | Can you also add a test with an all-constant phi, in which case the freeze will get dropped completely? I believe the code also handles that case. |
llvm/test/Transforms/InstCombine/freeze-phi.ll | ||
---|---|---|
216 | Seems like InstSimplify already deals with the case: function const in this file has a phi with constants. |
LGTM
As a possible followup: This code could be generalized a bit by using "constant && !constexpr" for non-freeze and "guaranteed-not-undef" (without any constant checks) for freeze, with some appropriate renames. This would basically change the transform from splitting into "constant" and "non-constant" inputs, into "foldable" and "non-foldable" inputs (where "foldable = constant" for most cases).
llvm/test/Transforms/InstCombine/freeze-phi.ll | ||
---|---|---|
216 | Oh right, that makes sense. In that case the whole phi is "guaranteed not undef", so we don't ever get here. |
It makes sense; freeze is simply no-op for a non-undef/poison constexpr, so it should work.
clang-format not found in user's PATH; not linting file.