This patch is the first effort to adding basic optimizations for FREEZE in SelDag.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
11593 | Why are we creating a new freeze x when we already have freeze x in the form of N0? |
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
11593 | You're right, it is fine to return N0. It was there because I was watching implementation of visitBITCAST. |
BTW, I tried to write a unit test that checks the freeze(freeze) -> freeze folding, but simply making llc print assembly wasn't enough to distinguish its effect. Is there a commandline option that prints SelDag just after dagcombiner?
You could try something like "-stop-before=finalize-isel" and then check the MIR for an extra COPY instruction.
See llvm/test/CodeGen/X86/sqrt-fastmath-mir.ll for an example of that type of regression test.
Thank you, I added a test.
llvm/test/CodeGen/X86/freeze-combine.ll | ||
---|---|---|
18 | This COPY seems to appear regardless of how many freezes are nested. |
LGTM - I'm not sure if we should also do these folds in SelectionDAGBuilder / getNode(), but that can be another patch if needed.
clang-format: please reformat the code