12e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd//===- llvm/Transforms/Utils/BypassSlowDivision.h --------------*- C++ -*-===// 22e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// 32e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// The LLVM Compiler Infrastructure 42e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// 52e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// This file is distributed under the University of Illinois Open Source 62e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// License. See LICENSE.TXT for details. 72e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// 82e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd//===----------------------------------------------------------------------===// 92e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// 102e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// This file contains an optimization for div and rem on architectures that 112e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// execute short instructions significantly faster than longer instructions. 122e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// For example, on Intel Atom 32-bit divides are slow enough that during 132e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// runtime it is profitable to check the value of the operands, and if they are 142e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// positive and less than 256 use an unsigned 8-bit divide. 152e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd// 162e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd//===----------------------------------------------------------------------===// 172e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd 18674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#ifndef LLVM_TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H 19674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#define LLVM_TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H 202e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd 21d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth#include "llvm/ADT/DenseMap.h" 220b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruth#include "llvm/IR/Function.h" 232e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd 2404142bc845c513141046e852db86670505459416Benjamin Kramernamespace llvm { 2504142bc845c513141046e852db86670505459416Benjamin Kramer 262e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd/// This optimization identifies DIV instructions that can be 272e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd/// profitably bypassed and carried out with a shorter, faster divide. 2804142bc845c513141046e852db86670505459416Benjamin Kramerbool bypassSlowDivision(Function &F, 2904142bc845c513141046e852db86670505459416Benjamin Kramer Function::iterator &I, 308d662b59f075da67e663ed142ecdd58e381eee98Preston Gurd const DenseMap<unsigned int, unsigned int> &BypassWidth); 3104142bc845c513141046e852db86670505459416Benjamin Kramer 3204142bc845c513141046e852db86670505459416Benjamin Kramer} // End llvm namespace 332e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd 342e2efd960056bbb7e4bbd843c8de55116d52aa7dPreston Gurd#endif 35