[PATCH] Teach IndVarSimplify to add nuw and nsw to operations that provably don't overflow.

Chandler Carruth chandlerc at google.com
Tue Dec 23 16:40:47 PST 2014


On Tue, Dec 23, 2014 at 4:31 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> > I am not aware of transforms that are valid only on overflowing
> > operators: as far as I can tell, adding nsw / nuw is a strict
> > increase in the amount of information there is available about an
> > instruction.  Can you give me some pointers on where to look for
> > examples?  Don't bother if you don't have them handy, I'll look for
> > them myself later.
>
> We really need to add this to an FAQ somewhere, it comes up a lot...
>
> For example, see slides 20-31 of
> http://llvm.org/devmtg/2014-10/Slides/Menendez-Alive.pdf -- shows a
> reassociation example valid only without the no-wrap flags. There are other
> examples too that have been discussed on the mailing list.
>

Perhaps it would help to explain it slightly differently: There are
optimizations which we can only perform by *removing* any no-wrap flags.
But we don't know whether that optimization or the no-wrap flags is more
important, and so we have to make a choice, and the choice is to preserve
the flags at the expense of the transformation. Thus, adding flags can
reduce the set of combines which actually occur even though they don't
reduce the set of combines which are valid.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141223/45778c18/attachment.html>


More information about the llvm-commits mailing list