]> granicus.if.org Git - llvm/commit
ScalarEvolution: Add URem support
authorAlexandre Isoard <alexandre.isoard@gmail.com>
Thu, 29 Jun 2017 16:29:04 +0000 (16:29 +0000)
committerAlexandre Isoard <alexandre.isoard@gmail.com>
Thu, 29 Jun 2017 16:29:04 +0000 (16:29 +0000)
commita70a8a0aa7aba9190a6fdc60c1a7ddbbfd54a81f
treedc0409982aa7f614b3e47aa57dff6cd49a4233f5
parent11eef886481cb0ee278265e8addafb119e80010f
ScalarEvolution: Add URem support

In LLVM IR the following code:

    %r = urem <ty> %t, %b

is equivalent to:

    %q = udiv <ty> %t, %b
    %s = mul <ty> nuw %q, %b
    %r = sub <ty> nuw %t, %q ; (t / b) * b + (t % b) = t

As UDiv, Mul and Sub are already supported by SCEV, URem can be
implemented with minimal effort this way.

Note: While SRem and SDiv are also related this way, SCEV does not
provides SDiv yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306695 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/flattened.ll [new file with mode: 0644]
test/Analysis/ScalarEvolution/urem-0.ll [new file with mode: 0644]