This is an archive of the discontinued LLVM Phabricator instance.

[APInt] Add saturating truncation methods
ClosedPublic

Authored by lebedev.ri on Nov 8 2019, 1:13 AM.

Details

Summary

The signed one is needed for implementation of ConstantRange::smul_sat(),
unsigned is for completeness only.

Diff Detail

Event Timeline

lebedev.ri created this revision.Nov 8 2019, 1:13 AM
nikic accepted this revision.Nov 8 2019, 1:21 AM

LGTM

I feel like the names are a bit inconsistent with existing uadd_sat etc, but utrunc_sat seems worse than truncUSat, so let's just go with it...

This revision is now accepted and ready to land.Nov 8 2019, 1:21 AM

LGTM

I feel like the names are a bit inconsistent with existing uadd_sat etc, but utrunc_sat seems worse than truncUSat, so let's just go with it...

Yes, i'm on the fence regarding names here.
I initially used trunc{Unsigned,Sign/Signed}Sat(), but that didn't seem much better..

This revision was automatically updated to reflect the committed changes.