2015-07-08 17:58 GMT+02:00 escha <escha at apple.com>:> [...] > > If you want to “revert" this sort of thing, you can do it at Select() time > or PreprocessISelDAG(), which is what I did on an out-of-tree backend to > turn add X, -C into sub X, C on selection time. This still lets all the > intermediate optimizations take advantage of the canonicalization. > > —eschaUnaware of your proposal, I used the TargetLowering::PerformDAGCombine hook. Is there a reason to prefere PreprocessISelDAG ? -- Fred -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150710/12e26aab/attachment.html>
Krzysztof Parzyszek
2015-Jul-10 12:55 UTC
[LLVMdev] Why change "sub x, 5" to "add x, -5" ?
On 7/10/2015 2:22 AM, Frédéric Heitzmann wrote:> > > Unaware of your proposal, I used the TargetLowering::PerformDAGCombine hook. > Is there a reason to prefere PreprocessISelDAG ?Target-specific PerformDAGCombine only runs when the standard combiner doesn't do anything. Also, various legalization steps can potentially undo what it did. PreprocessISelDAG runs always and there is nothing to get in its way. -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
> On Jul 10, 2015, at 12:22 AM, Frédéric Heitzmann <frederic.heitzmann at gmail.com> wrote: > > > > 2015-07-08 17:58 GMT+02:00 escha <escha at apple.com <mailto:escha at apple.com>>: > [...] > > If you want to “revert" this sort of thing, you can do it at Select() time or PreprocessISelDAG(), which is what I did on an out-of-tree backend to turn add X, -C into sub X, C on selection time. This still lets all the intermediate optimizations take advantage of the canonicalization. > > —escha > > Unaware of your proposal, I used the TargetLowering::PerformDAGCombine hook. > Is there a reason to prefere PreprocessISelDAG ?If you write a target-specific combine that conflicts with a canonicalization, it’ll infinite loop because it’ll oscillate between the two forms. —escha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150710/1720e4ea/attachment.html>
2015-07-10 16:53 GMT+02:00 escha <escha at apple.com>:> > If you write a target-specific combine that conflicts with a > canonicalization, it’ll infinite loop because it’ll oscillate between the > two forms. > >I saw that ;-) However, I used DAGCombinerInfo::CombineTo(oldNode, newNode, false) to prevent DAGCombiner to add the returned SDValue to worklist and recombine it back to the canical form. Did I miss the purpose of CombineTo ? fred -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150710/071e54c0/attachment.html>