This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by lebedev.ri on Nov 8 2019, 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.Nov 8 2019, 1:13 AM
lebedev.ri edited the summary of this revision. (Show Details)Nov 8 2019, 1:18 AM
nikic accepted this revision.Nov 8 2019, 5:55 AM

LGTM

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