This is an archive of the discontinued LLVM Phabricator instance.

[APInt} Add saturating left-shift ops
ClosedPublic

Authored by lebedev.ri on Oct 24 2019, 10:47 AM.

Details

Summary

There are *_ov() functions already, so at least for consistency it may be good to also have saturating variants.
These may or may not be needed for ConstantRange's shlWithNoWrap()

Diff Detail

Event Timeline

lebedev.ri created this revision.Oct 24 2019, 10:47 AM
nikic accepted this revision.Oct 24 2019, 11:49 AM

LGTM

llvm/unittests/ADT/APIntTest.cpp
1225

It's a bit weird that out-of-bounds shift amounts have well-defined behavior here, but as this is an existing behavior of shl_ov, I guess it makes sense.

This revision is now accepted and ready to land.Oct 24 2019, 11:49 AM
This revision was automatically updated to reflect the committed changes.