[llvm] r185257 - InstCombine: Be more agressive optimizing 'udiv' instrs with 'select' denoms

David Majnemer david.majnemer at gmail.com
Sat Jun 29 14:27:37 PDT 2013


On Sat, Jun 29, 2013 at 10:07 AM, Chris Lattner <clattner at apple.com> wrote:

>
> On Jun 29, 2013, at 10:02 AM, David Majnemer <david.majnemer at gmail.com>
> wrote:
>
> > I can check all the operands twice or just not do the transform. I don't
> readily see a nicer alternative but I am receptive to suggestions!
> >
> > I figured that divides are worth annihilating with vigor due to how
> expensive they are and hoped they would be sufficiently uncommon that any
> wasted effort would be in the noise.
>
> Eli is right though, this will burn compiler performance in cases that
> won't matter.  Remember that instcombine is run multiple times through the
> compiler flow.
>

Attached is a patch that doesn't create any new instructions unless it is
able to fold the udiv away.
It splits the work into two steps, analysis and folding. It tried my best
to not add overhead to the folding stage by assuming the analysis step gave
me good arguments.
It is fairly quick and dirty but I wanted to make sure that this was along
the lines of what you expected/imagined before I add comments/cleanup/etc.
I wouldn't be surprised if you had something different in mind as I find
this solution less than elegant.


>
> > If its any consolation, this transform fires on LLVM itself.
>
> Sounds like a great optimization, we just need a more efficient
> implementation :)
>
> -Chris
>
>
Thanks
-- 
David Majnemer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130629/6c31336d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: two-stage.diff
Type: application/octet-stream
Size: 7377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130629/6c31336d/attachment.obj>


More information about the llvm-commits mailing list