This is an archive of the discontinued LLVM Phabricator instance.

[ConstantRange] Add API for intrinsics (NFC)
ClosedPublic

Authored by nikic on Jul 25 2020, 7:56 AM.

Details

Summary

This adds a common API for compute constant ranges of intrinsics. The intention here is that
a) we can reuse the same code across different passes that handle constant ranges, i.e. this can be reused in SCCP
b) we only have to add knowledge about supported intrinsics to ConstantRange, not any consumers.

Diff Detail

Event Timeline

nikic created this revision.Jul 25 2020, 7:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2020, 7:56 AM
nikic retitled this revision from [ConstantRange] Add API for intrinsics to [ConstantRange] Add API for intrinsics (NFC).Jul 25 2020, 7:56 AM
fhahn accepted this revision.Jul 27 2020, 3:18 AM

LGTM, this makes sense to enable wider use and is in line with existing members like binaryOp. Thanks!

llvm/include/llvm/IR/ConstantRange.h
153

Nit: mentioning explicitly what is returned seems a bit clearer to me, .e.g Returns true if ConstantRange calculations are supported for intrinsic with \p IntrinsicID.

llvm/lib/IR/ConstantRange.cpp
863

maybe we should assert(!isIntrinsicSupported(IntrinsicID)) here, to catch (some) inconsistencies between isIntrinsicSupported and intrinsic

This revision is now accepted and ready to land.Jul 27 2020, 3:18 AM
This revision was landed with ongoing or failed builds.Jul 29 2020, 1:16 PM
This revision was automatically updated to reflect the committed changes.
nikic marked 2 inline comments as done.