This is an archive of the discontinued LLVM Phabricator instance.

[Docs] clarify that the x.with.overflow intrinsics have defined behavior for all inputs
ClosedPublic

Authored by regehr on May 11 2016, 1:16 AM.

Details

Summary

I mirrored the text in the clang language extensions document as closely as possible.

Diff Detail

Repository
rL LLVM

Event Timeline

regehr updated this revision to Diff 56858.May 11 2016, 1:16 AM
regehr retitled this revision from to [Docs] clarify that the x.with.overflow intrinsics have defined behavior for all inputs.
regehr updated this object.
regehr added reviewers: sanjoy, reames, nlopes, majnemer.
regehr set the repository for this revision to rL LLVM.
majnemer accepted this revision.May 11 2016, 9:59 AM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.May 11 2016, 9:59 AM
sanjoy added inline comments.May 11 2016, 12:03 PM
docs/LangRef.rst
10864 ↗(On Diff #56858)

I'm not sure that we need to special case "mathematically correct". Why not say something like: "the first result is the operation modulo 2^bitwidth, and the second result is 1 iff the operation overflowed."

A more pertinent bit of information here is what is defined to be an overflow: an operation overflows if for any N, "ext(A op B) to iN != (ext(A) to iN) op (ext(B) to iN)" where ext is sext for sign overflow and zext for unsigned overflow.

regehr added inline comments.May 11 2016, 12:20 PM
docs/LangRef.rst
10864 ↗(On Diff #56858)

Sure. I had been aiming for wording congruent with the clang manual, if we give up on that it's possible to say things a bit better.

regehr updated this revision to Diff 57002.May 12 2016, 1:27 AM
regehr edited edge metadata.

revise wording as suggested by Sanjoy

regehr marked 2 inline comments as done.May 12 2016, 1:27 AM
regehr updated this revision to Diff 57004.May 12 2016, 1:33 AM

fix misspelling

sanjoy accepted this revision.May 12 2016, 11:50 AM
sanjoy edited edge metadata.

lgtm, with an optional-to-fix nit

docs/LangRef.rst
10863 ↗(On Diff #57004)

What I had in mind was:

Each of these intrinsics returns a two-element struct. The first
element of this struct contains the result of the corresponding
arithmetic operation modulo 2\ :sup:`n`\ , where n is the
bit width of the result.

I.e. I don't see a need to special case the overflow or no-overflow
situation -- the operation is always modulo 2^n

But I'm okay with what you have.

Closed by commit rL269346 (authored by regehr). · Explain WhyMay 12 2016, 2:01 PM
This revision was automatically updated to reflect the committed changes.