003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/Transforms/Scalar
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
Transforms
/
Scalar
/
📁
..
📄
ADCE.h
(1.38 KB)
📄
AlignmentFromAssumptions.h
(1.6 KB)
📄
BDCE.h
(1.04 KB)
📄
CallSiteSplitting.h
(810 B)
📄
ConstantHoisting.h
(8.02 KB)
📄
CorrelatedValuePropagation.h
(810 B)
📄
DCE.h
(892 B)
📄
DeadStoreElimination.h
(1.2 KB)
📄
DivRemPairs.h
(1.01 KB)
📄
EarlyCSE.h
(1.41 KB)
📄
Float2Int.h
(1.74 KB)
📄
GVN.h
(12.57 KB)
📄
GVNExpression.h
(20.21 KB)
📄
GuardWidening.h
(1.18 KB)
📄
IVUsersPrinter.h
(960 B)
📄
IndVarSimplify.h
(1.03 KB)
📄
InductiveRangeCheckElimination.h
(950 B)
📄
InstSimplifyPass.h
(1.64 KB)
📄
JumpThreading.h
(6.55 KB)
📄
LICM.h
(2.78 KB)
📄
LoopAccessAnalysisPrinter.h
(999 B)
📄
LoopDataPrefetch.h
(1.06 KB)
📄
LoopDeletion.h
(1.13 KB)
📄
LoopDistribute.h
(1.08 KB)
📄
LoopFuse.h
(876 B)
📄
LoopIdiomRecognize.h
(1.18 KB)
📄
LoopInstSimplify.h
(1.07 KB)
📄
LoopLoadElimination.h
(1.1 KB)
📄
LoopPassManager.h
(15.85 KB)
📄
LoopPredication.h
(1.12 KB)
📄
LoopRotation.h
(1.13 KB)
📄
LoopSimplifyCFG.h
(1.31 KB)
📄
LoopSink.h
(1.54 KB)
📄
LoopStrengthReduce.h
(1.52 KB)
📄
LoopUnrollAndJamPass.h
(921 B)
📄
LoopUnrollPass.h
(4.97 KB)
📄
LowerAtomic.h
(974 B)
📄
LowerConstantIntrinsics.h
(1.4 KB)
📄
LowerExpectIntrinsic.h
(1.25 KB)
📄
LowerGuardIntrinsic.h
(992 B)
📄
LowerMatrixIntrinsics.h
(868 B)
📄
LowerWidenableCondition.h
(937 B)
📄
MakeGuardsExplicit.h
(1.85 KB)
📄
MemCpyOptimizer.h
(2.71 KB)
📄
MergeICmps.h
(714 B)
📄
MergedLoadStoreMotion.h
(2.02 KB)
📄
NaryReassociate.h
(6.98 KB)
📄
NewGVN.h
(935 B)
📄
PartiallyInlineLibCalls.h
(1.04 KB)
📄
Reassociate.h
(4.6 KB)
📄
RewriteStatepointsForGC.h
(1.27 KB)
📄
SCCP.h
(1.81 KB)
📄
SROA.h
(5.29 KB)
📄
Scalarizer.h
(1.18 KB)
📄
SimpleLoopUnswitch.h
(3.35 KB)
📄
SimplifyCFG.h
(2.01 KB)
📄
Sink.h
(998 B)
📄
SpeculateAroundPHIs.h
(3.69 KB)
📄
SpeculativeExecution.h
(3.04 KB)
📄
TailRecursionElimination.h
(3.3 KB)
📄
WarnMissedTransforms.h
(1.19 KB)
Editing: Reassociate.h
//===- Reassociate.h - Reassociate binary expressions -----------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This pass reassociates commutative expressions in an order that is designed // to promote better constant propagation, GCSE, LICM, PRE, etc. // // For example: 4 + (x + 5) -> x + (4 + 5) // // In the implementation of this algorithm, constants are assigned rank = 0, // function arguments are rank = 1, and other values are assigned ranks // corresponding to the reverse post order traversal of current function // (starting at 2), which effectively gives values in deep loops higher rank // than values not in loops. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_SCALAR_REASSOCIATE_H #define LLVM_TRANSFORMS_SCALAR_REASSOCIATE_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/SetVector.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/ValueHandle.h" #include <deque> namespace llvm { class APInt; class BasicBlock; class BinaryOperator; class Function; class Instruction; class IRBuilderBase; class Value; /// A private "module" namespace for types and utilities used by Reassociate. /// These are implementation details and should not be used by clients. namespace reassociate { struct ValueEntry { unsigned Rank; Value *Op; ValueEntry(unsigned R, Value *O) : Rank(R), Op(O) {} }; inline bool operator<(const ValueEntry &LHS, const ValueEntry &RHS) { return LHS.Rank > RHS.Rank; // Sort so that highest rank goes to start. } /// Utility class representing a base and exponent pair which form one /// factor of some product. struct Factor { Value *Base; unsigned Power; Factor(Value *Base, unsigned Power) : Base(Base), Power(Power) {} }; class XorOpnd; } // end namespace reassociate /// Reassociate commutative expressions. class ReassociatePass : public PassInfoMixin<ReassociatePass> { public: using OrderedSet = SetVector<AssertingVH<Instruction>, std::deque<AssertingVH<Instruction>>>; protected: DenseMap<BasicBlock *, unsigned> RankMap; DenseMap<AssertingVH<Value>, unsigned> ValueRankMap; OrderedSet RedoInsts; // Arbitrary, but prevents quadratic behavior. static const unsigned GlobalReassociateLimit = 10; static const unsigned NumBinaryOps = Instruction::BinaryOpsEnd - Instruction::BinaryOpsBegin; struct PairMapValue { WeakVH Value1; WeakVH Value2; unsigned Score; bool isValid() const { return Value1 && Value2; } }; DenseMap<std::pair<Value *, Value *>, PairMapValue> PairMap[NumBinaryOps]; bool MadeChange; public: PreservedAnalyses run(Function &F, FunctionAnalysisManager &); private: void BuildRankMap(Function &F, ReversePostOrderTraversal<Function *> &RPOT); unsigned getRank(Value *V); void canonicalizeOperands(Instruction *I); void ReassociateExpression(BinaryOperator *I); void RewriteExprTree(BinaryOperator *I, SmallVectorImpl<reassociate::ValueEntry> &Ops); Value *OptimizeExpression(BinaryOperator *I, SmallVectorImpl<reassociate::ValueEntry> &Ops); Value *OptimizeAdd(Instruction *I, SmallVectorImpl<reassociate::ValueEntry> &Ops); Value *OptimizeXor(Instruction *I, SmallVectorImpl<reassociate::ValueEntry> &Ops); bool CombineXorOpnd(Instruction *I, reassociate::XorOpnd *Opnd1, APInt &ConstOpnd, Value *&Res); bool CombineXorOpnd(Instruction *I, reassociate::XorOpnd *Opnd1, reassociate::XorOpnd *Opnd2, APInt &ConstOpnd, Value *&Res); Value *buildMinimalMultiplyDAG(IRBuilderBase &Builder, SmallVectorImpl<reassociate::Factor> &Factors); Value *OptimizeMul(BinaryOperator *I, SmallVectorImpl<reassociate::ValueEntry> &Ops); Value *RemoveFactorFromExpression(Value *V, Value *Factor); void EraseInst(Instruction *I); void RecursivelyEraseDeadInsts(Instruction *I, OrderedSet &Insts); void OptimizeInst(Instruction *I); Instruction *canonicalizeNegFPConstantsForOp(Instruction *I, Instruction *Op, Value *OtherOp); Instruction *canonicalizeNegFPConstants(Instruction *I); void BuildPairMap(ReversePostOrderTraversal<Function *> &RPOT); }; } // end namespace llvm #endif // LLVM_TRANSFORMS_SCALAR_REASSOCIATE_H
Upload File
Create Folder