File indexing completed on 2026-05-10 08:43:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H
0032 #define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H
0033
0034 #include "llvm/Analysis/SimplifyQuery.h"
0035 #include "llvm/IR/FPEnv.h"
0036
0037 namespace llvm {
0038
0039 template <typename T, typename... TArgs> class AnalysisManager;
0040 template <class T> class ArrayRef;
0041 class AssumptionCache;
0042 class CallBase;
0043 class DataLayout;
0044 class DominatorTree;
0045 class Function;
0046 class Instruction;
0047 class CmpPredicate;
0048 class LoadInst;
0049 struct LoopStandardAnalysisResults;
0050 class Pass;
0051 template <class T, unsigned n> class SmallSetVector;
0052 class TargetLibraryInfo;
0053 class Type;
0054 class Value;
0055
0056
0057
0058
0059
0060
0061 Value *simplifyAddInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW,
0062 const SimplifyQuery &Q);
0063
0064
0065 Value *simplifySubInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW,
0066 const SimplifyQuery &Q);
0067
0068
0069 Value *simplifyMulInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW,
0070 const SimplifyQuery &Q);
0071
0072
0073 Value *simplifySDivInst(Value *LHS, Value *RHS, bool IsExact,
0074 const SimplifyQuery &Q);
0075
0076
0077 Value *simplifyUDivInst(Value *LHS, Value *RHS, bool IsExact,
0078 const SimplifyQuery &Q);
0079
0080
0081 Value *simplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
0082
0083
0084 Value *simplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
0085
0086
0087 Value *simplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q);
0088
0089
0090
0091 Value *
0092 simplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF,
0093 const SimplifyQuery &Q,
0094 fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
0095 RoundingMode Rounding = RoundingMode::NearestTiesToEven);
0096
0097
0098 Value *
0099 simplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF,
0100 const SimplifyQuery &Q,
0101 fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
0102 RoundingMode Rounding = RoundingMode::NearestTiesToEven);
0103
0104
0105 Value *
0106 simplifyFMulInst(Value *LHS, Value *RHS, FastMathFlags FMF,
0107 const SimplifyQuery &Q,
0108 fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
0109 RoundingMode Rounding = RoundingMode::NearestTiesToEven);
0110
0111
0112
0113
0114
0115 Value *simplifyFMAFMul(Value *LHS, Value *RHS, FastMathFlags FMF,
0116 const SimplifyQuery &Q,
0117 fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
0118 RoundingMode Rounding = RoundingMode::NearestTiesToEven);
0119
0120
0121 Value *
0122 simplifyFDivInst(Value *LHS, Value *RHS, FastMathFlags FMF,
0123 const SimplifyQuery &Q,
0124 fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
0125 RoundingMode Rounding = RoundingMode::NearestTiesToEven);
0126
0127
0128 Value *
0129 simplifyFRemInst(Value *LHS, Value *RHS, FastMathFlags FMF,
0130 const SimplifyQuery &Q,
0131 fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
0132 RoundingMode Rounding = RoundingMode::NearestTiesToEven);
0133
0134
0135 Value *simplifyShlInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
0136 const SimplifyQuery &Q);
0137
0138
0139 Value *simplifyLShrInst(Value *Op0, Value *Op1, bool IsExact,
0140 const SimplifyQuery &Q);
0141
0142
0143 Value *simplifyAShrInst(Value *Op0, Value *Op1, bool IsExact,
0144 const SimplifyQuery &Q);
0145
0146
0147 Value *simplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
0148
0149
0150 Value *simplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
0151
0152
0153 Value *simplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
0154
0155
0156 Value *simplifyICmpInst(CmpPredicate Pred, Value *LHS, Value *RHS,
0157 const SimplifyQuery &Q);
0158
0159
0160 Value *simplifyFCmpInst(CmpPredicate Predicate, Value *LHS, Value *RHS,
0161 FastMathFlags FMF, const SimplifyQuery &Q);
0162
0163
0164 Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
0165 const SimplifyQuery &Q);
0166
0167
0168 Value *simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef<Value *> Indices,
0169 GEPNoWrapFlags NW, const SimplifyQuery &Q);
0170
0171
0172 Value *simplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs,
0173 const SimplifyQuery &Q);
0174
0175
0176 Value *simplifyInsertElementInst(Value *Vec, Value *Elt, Value *Idx,
0177 const SimplifyQuery &Q);
0178
0179
0180 Value *simplifyExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
0181 const SimplifyQuery &Q);
0182
0183
0184 Value *simplifyExtractElementInst(Value *Vec, Value *Idx,
0185 const SimplifyQuery &Q);
0186
0187
0188 Value *simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty,
0189 const SimplifyQuery &Q);
0190
0191
0192 Value *simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType, Value *Op0,
0193 Value *Op1, const SimplifyQuery &Q,
0194 const CallBase *Call);
0195
0196
0197
0198 Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef<int> Mask,
0199 Type *RetTy, const SimplifyQuery &Q);
0200
0201
0202
0203
0204 Value *simplifyCmpInst(CmpPredicate Predicate, Value *LHS, Value *RHS,
0205 const SimplifyQuery &Q);
0206
0207
0208 Value *simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q);
0209
0210
0211
0212 Value *simplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF,
0213 const SimplifyQuery &Q);
0214
0215
0216 Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
0217 const SimplifyQuery &Q);
0218
0219
0220
0221 Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, FastMathFlags FMF,
0222 const SimplifyQuery &Q);
0223
0224
0225 Value *simplifyCall(CallBase *Call, Value *Callee, ArrayRef<Value *> Args,
0226 const SimplifyQuery &Q);
0227
0228
0229
0230
0231
0232
0233
0234
0235 Value *simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q);
0236
0237
0238
0239 Value *simplifyFreezeInst(Value *Op, const SimplifyQuery &Q);
0240
0241
0242
0243 Value *simplifyLoadInst(LoadInst *LI, Value *PtrOp, const SimplifyQuery &Q);
0244
0245
0246
0247 Value *simplifyInstruction(Instruction *I, const SimplifyQuery &Q);
0248
0249
0250
0251 Value *
0252 simplifyInstructionWithOperands(Instruction *I, ArrayRef<Value *> NewOps,
0253 const SimplifyQuery &Q);
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264 Value *
0265 simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
0266 const SimplifyQuery &Q, bool AllowRefinement,
0267 SmallVectorImpl<Instruction *> *DropFlags = nullptr);
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278 bool replaceAndRecursivelySimplify(
0279 Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI = nullptr,
0280 const DominatorTree *DT = nullptr, AssumptionCache *AC = nullptr,
0281 SmallSetVector<Instruction *, 8> *UnsimplifiedUsers = nullptr);
0282
0283
0284
0285
0286 const SimplifyQuery getBestSimplifyQuery(Pass &, Function &);
0287 template <class T, class... TArgs>
0288 const SimplifyQuery getBestSimplifyQuery(AnalysisManager<T, TArgs...> &,
0289 Function &);
0290 const SimplifyQuery getBestSimplifyQuery(LoopStandardAnalysisResults &,
0291 const DataLayout &);
0292 }
0293
0294 #endif