[PATCH] D41944: [LLVM][IR][LIT] support of 'no-overflow' flag for sdiv\udiv instructions

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 15 17:15:20 PST 2018


efriedma added a comment.

In https://reviews.llvm.org/D41944#974178, @sanjoy wrote:

> This looks like something that will be better served by an intrinsic (`llvm.safe_(s|u)div` or something like that), at least to begin with.  Experimental intrinsics are a low-cost preferred way of trying out ideas like this without changing fundamental IR semantics.


I was the one who originally suggested the nof flag.  Using the same IR representation for the same computation is nice for many reasons, which is why we have, for example, nsw, or the boolean flag to llvm.ctlz.  And I think it's pretty clearly the design we would have used if the IR weren't originally designed around the limitations of x86.

If we're not confident the non-nof div is actually useful, we could call it "llvm.experimental.safe_(s|u)div" instead for now, I guess.  The lowering/SelectionDAG work required for that is almost identical, so it wouldn't be hard to switch later.

-----

The initial patch should probably be "complete", in the sense of being able to lower the safe divide.  All you need for that is an IR lowering pass to convert a potentially-overflowing divide into a control flow around a conventional udiv/sdiv.  (We probably want that anyway, for approximately the same reasons we have the ScalarizeMaskedMemIntrin pass.)


Repository:
  rL LLVM

https://reviews.llvm.org/D41944





More information about the llvm-commits mailing list