[LLVMdev] Why change "sub x, 5" to "add x, -5" ?

escha escha at apple.com
Fri Jul 10 07:53:43 PDT 2015


> 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>


More information about the llvm-dev mailing list