This is an archive of the discontinued LLVM Phabricator instance.

[LVI][CVP] Add support for saturating add/sub
ClosedPublic

Authored by nikic on May 25 2019, 2:57 AM.

Details

Summary

Adds support for the uadd.sat family of intrinsics in LVI, based on ConstantRange methods from D60946.

Diff Detail

Repository
rL LLVM

Event Timeline

nikic created this revision.May 25 2019, 2:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2019, 2:57 AM
lebedev.ri accepted this revision.May 25 2019, 3:30 AM

Still not any more familiar with CVP, but this looks rather identical to the solveBlockValueOverflowIntrinsic() change, so LG.
Up to you if you want to wait for one more signoff (@spatel ?)

llvm/lib/Analysis/LazyValueInfo.cpp
1122 ↗(On Diff #201397)

Have you considered adding a SaturatingInst base class, much like WithOverflowInst;
and/or saturatingBinaryOp, much like binaryOp, to ConstantRange?
I think that might potentially be a bit cleaner overall.
(Not for this patch)

This revision is now accepted and ready to land.May 25 2019, 3:30 AM
spatel accepted this revision.May 25 2019, 8:37 AM

LGTM

nikic marked an inline comment as done.May 25 2019, 9:34 AM
nikic added inline comments.
llvm/lib/Analysis/LazyValueInfo.cpp
1122 ↗(On Diff #201397)

Yeah, that might make sense. Having it (possibly even a common base class with WithOverflowInst) would be useful to extend https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp#L402 to saturating math.

This revision was automatically updated to reflect the committed changes.