[PATCH] D28199: [BypassSlowDivision] Use ValueTracking to simplify run-time checks

Nikolai Bozhenov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 31 07:02:25 PST 2016


n.bozhenov created this revision.
n.bozhenov added reviewers: spatel, craig.topper, bkramer, jlebar.
n.bozhenov added subscribers: llvm-commits, zansari, DavidKreitzer, aaboud, volkalexey.

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 enough then the long division is not needed any more. 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).


https://reviews.llvm.org/D28199

Files:
  lib/Transforms/Utils/BypassSlowDivision.cpp
  test/CodeGen/X86/bypass-slow-division-64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28199.82766.patch
Type: text/x-patch
Size: 10617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161231/5314247c/attachment.bin>


More information about the llvm-commits mailing list