[ConstantRange] Add urem support
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 23 Apr 2019 18:00:17 +0000 (18:00 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 23 Apr 2019 18:00:17 +0000 (18:00 +0000)
commitf945429fed52bc7c182d5b38469a41ab5eea03a2
tree889515937f2a75eb3cc36a63202bf45c8e583c27
parent4a52397965b7fdd168cc0f96f82e859b6139ce4f
[ConstantRange] Add urem support

Add urem support to ConstantRange, so we can handle in in LVI. This
is an approximate implementation that tries to capture the most useful
conditions: If the LHS is always strictly smaller than the RHS, then
the urem is a no-op and the result is the same as the LHS range.
Otherwise the lower bound is zero and the upper bound is
min(LHSMax, RHSMax - 1).

Differential Revision: https://reviews.llvm.org/D60952

llvm-svn: 359019
llvm/include/llvm/IR/ConstantRange.h
llvm/lib/IR/ConstantRange.cpp
llvm/unittests/IR/ConstantRangeTest.cpp