This is an archive of the discontinued LLVM Phabricator instance.

Integer division expansion should handle constant divisors intelligently
AbandonedPublic

Authored by dshtilman on Nov 17 2016, 3:38 PM.

Details

Reviewers
None
Summary

When expanding integer division by a constant, replace it with a simple multiplication by a magic number, rather than generating a full division loop.

Implementation follows the DAG code in TargetLowering::BuildSDIV().
Ref: "Hacker's Delight" or "The PowerPC Compiler Writer's Guide".

Diff Detail

Event Timeline

dshtilman updated this revision to Diff 78409.Nov 17 2016, 3:38 PM
dshtilman retitled this revision from to Integer division expansion should handle constant divisors intelligently.
dshtilman updated this object.
dshtilman set the repository for this revision to rL LLVM.
dshtilman added a subscriber: qcolombet.
dshtilman updated this revision to Diff 78430.Nov 17 2016, 4:09 PM
dshtilman removed rL LLVM as the repository for this revision.
dshtilman abandoned this revision.Nov 29 2016, 7:06 PM
joerg added a subscriber: joerg.Nov 30 2016, 3:18 AM

Why is this code necessary? LLVM already implements the division-by-constant optimisation.