This is an archive of the discontinued LLVM Phabricator instance.

[LVI][CVP] Add support for urem, srem and sdiv
ClosedPublic

Authored by nikic on Jun 3 2019, 1:45 PM.

Details

Summary

The underlying ConstantRange functionality has been added in D60952, D61207 and D61238, this just exposes it for LVI.

I'm switching the code from using a whitelist to a blacklist, as we're down to one unsupported operation here (xor) and writing it this way seems more obvious :)

Diff Detail

Event Timeline

nikic created this revision.Jun 3 2019, 1:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2019, 1:45 PM
reames requested changes to this revision.Jun 3 2019, 1:59 PM
reames added inline comments.
llvm/lib/IR/ConstantRange.cpp
792 ↗(On Diff #202783)

If I understand the context of the patch, xor is the only case not handled right? If so, then I'd strongly prefer to see a case handled for xor (even if that's simply return full). The contract of "supports all binops but xor" is not a great API for this function.

This revision now requires changes to proceed.Jun 3 2019, 1:59 PM
nikic updated this revision to Diff 202798.Jun 3 2019, 2:20 PM

Remove ConstantRange::binaryOp() assertion.

nikic marked 2 inline comments as done.Jun 3 2019, 2:22 PM
nikic added inline comments.
llvm/lib/IR/ConstantRange.cpp
792 ↗(On Diff #202783)

Xor is the only unsupported integer binop. There are more unsupported float binops which aren't relevant to LVI though.

I've restored the code to returning a conservative result now.

reames accepted this revision.Jun 3 2019, 2:51 PM

LGTM

This revision is now accepted and ready to land.Jun 3 2019, 2:51 PM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.