Page MenuHomePhabricator

[APInt] Add saturating truncation methods
ClosedPublic

Authored by lebedev.ri on Fri, Nov 8, 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.Fri, Nov 8, 1:13 AM
nikic accepted this revision.Fri, Nov 8, 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.Fri, Nov 8, 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.