forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- CodeGenPrepare pass for identifying div/rem ops - Backend specifies the type mapping using addBypassSlowDivType - Enabled only for Intel Atom with O2 32-bit -> 8-bit - Replace IDIV with instructions which test its value and use DIVB if the value is positive and less than 256. - In the case when the quotient and remainder of a divide are used a DIV and a REM instruction will be present in the IR. In the non-Atom case they are both lowered to IDIVs and CSE removes the redundant IDIV instruction, using the quotient and remainder from the first IDIV. However, due to this optimization CSE is not able to eliminate redundant IDIV instructions because they are located in different basic blocks. This is overcome by calculating both the quotient (DIV) and remainder (REM) in each basic block that is inserted by the optimization and reusing the result values when a subsequent DIV or REM instruction uses the same operands. - Test cases check for the presents of the optimization when calculating either the quotient, remainder, or both. Patch by Tyler Nowicki! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163150 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
11 changed files
with
473 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//===- llvm/Transforms/Utils/BypassSlowDivision.h --------------*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file contains an optimization for div and rem on architectures that | ||
// execute short instructions significantly faster than longer instructions. | ||
// For example, on Intel Atom 32-bit divides are slow enough that during | ||
// runtime it is profitable to check the value of the operands, and if they are | ||
// positive and less than 256 use an unsigned 8-bit divide. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H | ||
#define TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H | ||
|
||
#include "llvm/Function.h" | ||
|
||
/// This optimization identifies DIV instructions that can be | ||
/// profitably bypassed and carried out with a shorter, faster divide. | ||
bool bypassSlowDivision(llvm::Function &F, | ||
llvm::Function::iterator &I, | ||
const llvm::DenseMap<llvm::Type *, llvm::Type *> &BypassTypeMap); | ||
|
||
#endif | ||
//===- llvm/Transforms/Utils/BypassSlowDivision.h --------------*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file contains an optimization for div and rem on architectures that | ||
// execute short instructions significantly faster than longer instructions. | ||
// For example, on Intel Atom 32-bit divides are slow enough that during | ||
// runtime it is profitable to check the value of the operands, and if they are | ||
// positive and less than 256 use an unsigned 8-bit divide. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H | ||
#define TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H | ||
|
||
#include "llvm/Function.h" | ||
|
||
/// This optimization identifies DIV instructions that can be | ||
/// profitably bypassed and carried out with a shorter, faster divide. | ||
bool bypassSlowDivision(llvm::Function &F, | ||
llvm::Function::iterator &I, | ||
const llvm::DenseMap<llvm::Type *, llvm::Type *> &BypassTypeMap); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.