llvm-project/llvm/lib/Transforms/Utils
Weiming Zhao 8213072a45 [SimplifyLibCalls] Optimization for pow(x, n) where n is some constant
Summary:
    In order to avoid calling pow function we generate repeated fmul when n is a
    positive or negative whole number.
    
    For each exponent we pre-compute Addition Chains in order to minimize the no.
    of fmuls.
    Refer: http://wwwhomes.uni-bielefeld.de/achim/addition_chain.html
    
    We pre-compute addition chains for exponents upto 32 (which results in a max of
    7 fmuls).

    For eg:
    4 = 2+2
    5 = 2+3
    6 = 3+3 and so on
    
    Hence,
    pow(x, 4.0) ==> y = fmul x, x
                    x = fmul y, y
                    ret x

    For negative exponents, we simply compute the reciprocal of the final result.
    
    Note: This transformation is only enabled under fast-math.
    
    Patch by Mandeep Singh Grang <mgrang@codeaurora.org>

Reviewers: weimingz, majnemer, escha, davide, scanon, joerg

Subscribers: probinson, escha, llvm-commits

Differential Revision: http://reviews.llvm.org/D13994

llvm-svn: 254776
2015-12-04 22:00:47 +00:00
..
ASanStackFrameLayout.cpp [Utils] Put includes in correct order. NFC. 2015-11-24 18:57:06 +00:00
AddDiscriminators.cpp Fix the debug build breakage that getDiscriminator is called by mistake. 2015-11-19 20:29:27 +00:00
BasicBlockUtils.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
BreakCriticalEdges.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
BuildLibCalls.cpp [Utils] Put includes in correct order. NFC. 2015-11-24 18:57:06 +00:00
BypassSlowDivision.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
CMakeLists.txt TransformUtils: Introduce module splitter. 2015-08-21 02:48:20 +00:00
CloneFunction.cpp Teach the inliner to track deoptimization state 2015-11-18 06:23:38 +00:00
CloneModule.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
CmpInstAnalysis.cpp
CodeExtractor.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
CtorUtils.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
DemoteRegToStack.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
FlattenCFG.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
GlobalStatus.cpp GlobalOpt does not treat externally_initialized globals correctly 2015-10-12 13:20:52 +00:00
InlineFunction.cpp [OperandBundles] Extract duplicated code into a helper function, NFC 2015-11-25 00:42:24 +00:00
InstructionNamer.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
IntegerDivision.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
LCSSA.cpp [LCSSA] Unbreak build, don't reuse L; NFC 2015-10-25 19:27:17 +00:00
LLVMBuild.txt [PM/AA] Remove the last relics of the separate IPA library from LLVM, 2015-08-18 17:51:53 +00:00
Local.cpp Move EH-specific helper functions to a more appropriate place 2015-12-02 23:06:39 +00:00
LoopSimplify.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
LoopUnroll.cpp Revert r253253 and r253126: "Don't recompute LCSSA after loop-unrolling when possible." 2015-11-19 20:28:32 +00:00
LoopUnrollRuntime.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
LoopUtils.cpp [Utils] Put includes in correct order. NFC. 2015-11-24 18:57:06 +00:00
LoopVersioning.cpp [Utils] Put includes in correct order. NFC. 2015-11-24 18:57:06 +00:00
LowerInvoke.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
LowerSwitch.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
Makefile
Mem2Reg.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
MetaRenamer.cpp Whoops, remove trailing whitespace. 2015-08-27 05:37:12 +00:00
ModuleUtils.cpp [asan] Rename the ABI versioning symbol to '__asan_version_mismatch_check' instead of abusing '__asan_init' 2015-07-23 10:54:06 +00:00
PromoteMemoryToRegister.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
SSAUpdater.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
SimplifyCFG.cpp [Utils] Put includes in correct order. NFC. 2015-11-24 18:57:06 +00:00
SimplifyIndVar.cpp [IndVars] Preserve LCSSA in `eliminateIdentitySCEV` 2015-10-07 17:38:31 +00:00
SimplifyInstructions.cpp [Utils] Put includes in correct order. NFC. 2015-11-24 18:57:06 +00:00
SimplifyLibCalls.cpp [SimplifyLibCalls] Optimization for pow(x, n) where n is some constant 2015-12-04 22:00:47 +00:00
SplitModule.cpp TransformUtils: Introduce module splitter. 2015-08-21 02:48:20 +00:00
SymbolRewriter.cpp Remove unnecessary includes 2015-08-08 00:41:53 +00:00
UnifyFunctionExitNodes.cpp TransformUtils: Remove implicit ilist iterator conversions, NFC 2015-10-13 02:39:05 +00:00
Utils.cpp
ValueMapper.cpp Bring r254336 back: 2015-12-01 15:19:48 +00:00