OSDN Git Service

[BypassSlowDivision] Use ValueTracking to simplify run-time checks
authorNikolai Bozhenov <nikolai.bozhenov@intel.com>
Thu, 2 Mar 2017 22:12:15 +0000 (22:12 +0000)
committerNikolai Bozhenov <nikolai.bozhenov@intel.com>
Thu, 2 Mar 2017 22:12:15 +0000 (22:12 +0000)
commitba60b2bba26cb059cf2618b30e9115691ecef5ec
tree8e718e3353a02edb99ae25560b4f8472cce03367
parentcc946df67a3aa6879792451d3db81f1723ed14d7
[BypassSlowDivision] Use ValueTracking to simplify run-time checks

ValueTracking is used for more thorough analysis of operands. Based on the
analysis, either run-time checks can be simplified (e.g. check only one operand
instead of two) or the transformation can be avoided. For example, it is quite
often the case that a divisor is promoted from a shorter type and run-time
checks for it are redundant.

With additional compile-time analysis of values, two special cases naturally
arise and are addressed by the patch:

 1) Both operands are known to be short enough. Then, the long division can be
    simply replaced with a short one without CFG modification.

 2) If a division is unsigned and the dividend is known to be short then the
    long division is not needed at all. Because if the divisor is too big for
    short division then the quotient is obviously zero (and the remainder is
    equal to the dividend). Actually, the division is not needed when
    (divisor > dividend).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296832 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/BypassSlowDivision.cpp
test/Transforms/CodeGenPrepare/NVPTX/bypass-slow-div-special-cases.ll [new file with mode: 0644]