Ryan Taylor via llvm-dev
2020-Feb-03 18:07 UTC
[llvm-dev] Eliminate some two entry PHI nodes - SimplifyCFG
SimplifyCFG FoldTwoEntryPhiNode looks to simplify all 2 entry phi nodes in a block, if it can't do them all then it won't do any and returns. There is a lot of code that is directly in this function geared toward this requirement. Is it possible currently to get this function (or pass) to simply fold "some" of the phis (without having to fold them all?). I understand that "Simplify"CFG isn't really meant for this type of thing but there is a lot of code that is re-usable to do this with some refactoring of this function and potentially some addition of target specifics. For some phis, it's beneficial to keep them as the generated COPYs can be coalesced away later in the pipe. For other phis (for example, phis with all or potentially partial imm ops), it would be nice to opt these to selects (cmovs). It would also be nice to have this opt prior to the rest of SimplifyCFG as it might enable SimplifyCFG to do a better job of simplifying by reducing the number of phis, etc... We could fold the imm ops in the target backend but there are complications/complexities with doing that and we'd also potentially miss out on earlier optimizations. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200203/c2164a02/attachment-0001.html>
Nicolai Hähnle via llvm-dev
2020-Feb-05 12:47 UTC
[llvm-dev] Eliminate some two entry PHI nodes - SimplifyCFG
Hi Ryan, On Mon, Feb 3, 2020 at 7:08 PM Ryan Taylor via llvm-dev <llvm-dev at lists.llvm.org> wrote:> SimplifyCFG FoldTwoEntryPhiNode looks to simplify all 2 entry phi nodes in a block, if it can't do them all then it won't do any and returns. There is a lot of code that is directly in this function geared toward this requirement. Is it possible currently to get this function (or pass) to simply fold "some" of the phis (without having to fold them all?). I understand that "Simplify"CFG isn't really meant for this type of thing but there is a lot of code that is re-usable to do this with some refactoring of this function and potentially some addition of target specifics. > > For some phis, it's beneficial to keep them as the generated COPYs can be coalesced away later in the pipe. For other phis (for example, phis with all or potentially partial imm ops), it would be nice to opt these to selects (cmovs). It would also be nice to have this opt prior to the rest of SimplifyCFG as it might enable SimplifyCFG to do a better job of simplifying by reducing the number of phis, etc...I don't see a significant problem in adding this to FoldTwoEntryPhiNodes. The relevant changes would be isolated to the initial loop over the phis, and would be somewhat parallel to the use of simplifyInstruction. The main question is to how to make this conditional on a per-target basis, i.e. how to properly define any relevant heuristics via TargetTransformInfo. Cheers, Nicolai -- Lerne, wie die Welt wirklich ist, aber vergiss niemals, wie sie sein sollte.
Ryan Taylor via llvm-dev
2020-Feb-05 12:52 UTC
[llvm-dev] Eliminate some two entry PHI nodes - SimplifyCFG
Conditional on the target supporting cmov? Though that's probably not optimal. On Wed, Feb 5, 2020, 7:47 AM Nicolai Hähnle <nhaehnle at gmail.com> wrote:> Hi Ryan, > > On Mon, Feb 3, 2020 at 7:08 PM Ryan Taylor via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > SimplifyCFG FoldTwoEntryPhiNode looks to simplify all 2 entry phi nodes > in a block, if it can't do them all then it won't do any and returns. There > is a lot of code that is directly in this function geared toward this > requirement. Is it possible currently to get this function (or pass) to > simply fold "some" of the phis (without having to fold them all?). I > understand that "Simplify"CFG isn't really meant for this type of thing but > there is a lot of code that is re-usable to do this with some refactoring > of this function and potentially some addition of target specifics. > > > > For some phis, it's beneficial to keep them as the generated COPYs can > be coalesced away later in the pipe. For other phis (for example, phis with > all or potentially partial imm ops), it would be nice to opt these to > selects (cmovs). It would also be nice to have this opt prior to the rest > of SimplifyCFG as it might enable SimplifyCFG to do a better job of > simplifying by reducing the number of phis, etc... > > I don't see a significant problem in adding this to > FoldTwoEntryPhiNodes. The relevant changes would be isolated to the > initial loop over the phis, and would be somewhat parallel to the use > of simplifyInstruction. > > The main question is to how to make this conditional on a per-target > basis, i.e. how to properly define any relevant heuristics via > TargetTransformInfo. > > Cheers, > Nicolai > > > > -- > Lerne, wie die Welt wirklich ist, > aber vergiss niemals, wie sie sein sollte. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200205/3e8b500b/attachment.html>
Seemingly Similar Threads
- Eliminate some two entry PHI nodes - SimplifyCFG
- _mm_lfence in both pathes of an if/else are hoisted by SimplfyCFG potentially breaking use as a speculation barrier
- Why MachineBasicBlcok doesn't have transferPredecessors() ?
- [RFC] Expressing preserved-relations between passes from different modules (was: Re: Linker issue)
- Condition code in DAGCombiner::visitFADDForFMACombine?