Page MenuHomePhabricator

[ConstantRange] Add umul_sat()/smul_sat() methods
ClosedPublic

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

Details

Summary

To be used in ConstantRange::mulWithNoOverflow(),
may in future be useful for when saturating shift/mul ops are added.

These are precise as far as i can tell.

I initially though i will need APInt::[us]mul_sat() for these,
but it turned out much simpler to do what ConstantRange::multiply()
does - perform multiplication in twice the bitwidth, and then truncate.
Though here we want saturating signed truncation.

Diff Detail

Event Timeline

lebedev.ri created this revision.Fri, Nov 8, 1:13 AM
lebedev.ri edited the summary of this revision. (Show Details)Fri, Nov 8, 1:18 AM
nikic accepted this revision.Fri, Nov 8, 5:55 AM

LGTM

This revision is now accepted and ready to land.Fri, Nov 8, 5:55 AM
This revision was automatically updated to reflect the committed changes.