LLVM  14.0.0git
InstructionSimplify.h
Go to the documentation of this file.
1 //===-- InstructionSimplify.h - Fold instrs into simpler forms --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares routines for folding instructions into simpler forms
10 // that do not require creating new instructions. This does constant folding
11 // ("add i32 1, 1" -> "2") but can also handle non-constant operands, either
12 // returning a constant ("and i32 %x, 0" -> "0") or an already existing value
13 // ("and i32 %x, %x" -> "%x"). If the simplification is also an instruction
14 // then it dominates the original instruction.
15 //
16 // These routines implicitly resolve undef uses. The easiest way to be safe when
17 // using these routines to obtain simplified values for existing instructions is
18 // to always replace all uses of the instructions with the resulting simplified
19 // values. This will prevent other code from seeing the same undef uses and
20 // resolving them to different values.
21 //
22 // These routines are designed to tolerate moderately incomplete IR, such as
23 // instructions that are not connected to basic blocks yet. However, they do
24 // require that all the IR that they encounter be valid. In particular, they
25 // require that all non-constant values be defined in the same function, and the
26 // same call context of that function (and not split between caller and callee
27 // contexts of a directly recursive call, for example).
28 //
29 // Additionally, these routines can't simplify to the instructions that are not
30 // def-reachable, meaning we can't just scan the basic block for instructions
31 // to simplify to.
32 //
33 //===----------------------------------------------------------------------===//
34 
35 #ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H
36 #define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H
37 
38 #include "llvm/IR/Instruction.h"
39 #include "llvm/IR/Operator.h"
40 #include "llvm/IR/PatternMatch.h"
41 
42 namespace llvm {
43 
44 template <typename T, typename... TArgs> class AnalysisManager;
45 template <class T> class ArrayRef;
46 class AssumptionCache;
47 class BinaryOperator;
48 class CallBase;
49 class DataLayout;
50 class DominatorTree;
51 class Function;
53 class MDNode;
55 class Pass;
56 template <class T, unsigned n> class SmallSetVector;
57 class TargetLibraryInfo;
58 class Type;
59 class Value;
60 
61 /// InstrInfoQuery provides an interface to query additional information for
62 /// instructions like metadata or keywords like nsw, which provides conservative
63 /// results if the users specified it is safe to use.
65  InstrInfoQuery(bool UMD) : UseInstrInfo(UMD) {}
67  bool UseInstrInfo = true;
68 
69  MDNode *getMetadata(const Instruction *I, unsigned KindID) const {
70  if (UseInstrInfo)
71  return I->getMetadata(KindID);
72  return nullptr;
73  }
74 
75  template <class InstT> bool hasNoUnsignedWrap(const InstT *Op) const {
76  if (UseInstrInfo)
77  return Op->hasNoUnsignedWrap();
78  return false;
79  }
80 
81  template <class InstT> bool hasNoSignedWrap(const InstT *Op) const {
82  if (UseInstrInfo)
83  return Op->hasNoSignedWrap();
84  return false;
85  }
86 
87  bool isExact(const BinaryOperator *Op) const {
88  if (UseInstrInfo && isa<PossiblyExactOperator>(Op))
89  return cast<PossiblyExactOperator>(Op)->isExact();
90  return false;
91  }
92 };
93 
94 struct SimplifyQuery {
95  const DataLayout &DL;
96  const TargetLibraryInfo *TLI = nullptr;
97  const DominatorTree *DT = nullptr;
98  AssumptionCache *AC = nullptr;
99  const Instruction *CxtI = nullptr;
100 
101  // Wrapper to query additional information for instructions like metadata or
102  // keywords like nsw, which provides conservative results if those cannot
103  // be safely used.
105 
106  /// Controls whether simplifications are allowed to constrain the range of
107  /// possible values for uses of undef. If it is false, simplifications are not
108  /// allowed to assume a particular value for a use of undef for example.
109  bool CanUseUndef = true;
110 
111  SimplifyQuery(const DataLayout &DL, const Instruction *CXTI = nullptr)
112  : DL(DL), CxtI(CXTI) {}
113 
115  const DominatorTree *DT = nullptr,
116  AssumptionCache *AC = nullptr,
117  const Instruction *CXTI = nullptr, bool UseInstrInfo = true,
118  bool CanUseUndef = true)
119  : DL(DL), TLI(TLI), DT(DT), AC(AC), CxtI(CXTI), IIQ(UseInstrInfo),
122  SimplifyQuery Copy(*this);
123  Copy.CxtI = I;
124  return Copy;
125  }
127  SimplifyQuery Copy(*this);
128  Copy.CanUseUndef = false;
129  return Copy;
130  }
131 
132  /// If CanUseUndef is true, returns whether \p V is undef.
133  /// Otherwise always return false.
134  bool isUndefValue(Value *V) const {
135  if (!CanUseUndef)
136  return false;
137 
138  using namespace PatternMatch;
139  return match(V, m_Undef());
140  }
141 };
142 
143 // NOTE: the explicit multiple argument versions of these functions are
144 // deprecated.
145 // Please use the SimplifyQuery versions in new code.
146 
147 /// Given operand for an FNeg, fold the result or return null.
148 Value *SimplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q);
149 
150 /// Given operands for an Add, fold the result or return null.
151 Value *SimplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW,
152  const SimplifyQuery &Q);
153 
154 /// Given operands for a Sub, fold the result or return null.
155 Value *SimplifySubInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW,
156  const SimplifyQuery &Q);
157 
158 /// Given operands for an FAdd, fold the result or return null.
159 Value *
160 SimplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF,
161  const SimplifyQuery &Q,
162  fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
164 
165 /// Given operands for an FSub, fold the result or return null.
166 Value *
167 SimplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF,
168  const SimplifyQuery &Q,
169  fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
171 
172 /// Given operands for an FMul, fold the result or return null.
173 Value *
174 SimplifyFMulInst(Value *LHS, Value *RHS, FastMathFlags FMF,
175  const SimplifyQuery &Q,
176  fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
178 
179 /// Given operands for the multiplication of a FMA, fold the result or return
180 /// null. In contrast to SimplifyFMulInst, this function will not perform
181 /// simplifications whose unrounded results differ when rounded to the argument
182 /// type.
183 Value *SimplifyFMAFMul(Value *LHS, Value *RHS, FastMathFlags FMF,
184  const SimplifyQuery &Q,
185  fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
187 
188 /// Given operands for a Mul, fold the result or return null.
189 Value *SimplifyMulInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
190 
191 /// Given operands for an SDiv, fold the result or return null.
192 Value *SimplifySDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
193 
194 /// Given operands for a UDiv, fold the result or return null.
195 Value *SimplifyUDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
196 
197 /// Given operands for an FDiv, fold the result or return null.
198 Value *
199 SimplifyFDivInst(Value *LHS, Value *RHS, FastMathFlags FMF,
200  const SimplifyQuery &Q,
201  fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
203 
204 /// Given operands for an SRem, fold the result or return null.
205 Value *SimplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
206 
207 /// Given operands for a URem, fold the result or return null.
208 Value *SimplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
209 
210 /// Given operands for an FRem, fold the result or return null.
211 Value *
212 SimplifyFRemInst(Value *LHS, Value *RHS, FastMathFlags FMF,
213  const SimplifyQuery &Q,
214  fp::ExceptionBehavior ExBehavior = fp::ebIgnore,
216 
217 /// Given operands for a Shl, fold the result or return null.
218 Value *SimplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW,
219  const SimplifyQuery &Q);
220 
221 /// Given operands for a LShr, fold the result or return null.
222 Value *SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact,
223  const SimplifyQuery &Q);
224 
225 /// Given operands for a AShr, fold the result or return nulll.
226 Value *SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact,
227  const SimplifyQuery &Q);
228 
229 /// Given operands for an And, fold the result or return null.
230 Value *SimplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
231 
232 /// Given operands for an Or, fold the result or return null.
233 Value *SimplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
234 
235 /// Given operands for an Xor, fold the result or return null.
236 Value *SimplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
237 
238 /// Given operands for an ICmpInst, fold the result or return null.
239 Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
240  const SimplifyQuery &Q);
241 
242 /// Given operands for an FCmpInst, fold the result or return null.
243 Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
244  FastMathFlags FMF, const SimplifyQuery &Q);
245 
246 /// Given operands for a SelectInst, fold the result or return null.
248  const SimplifyQuery &Q);
249 
250 /// Given operands for a GetElementPtrInst, fold the result or return null.
251 Value *SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops,
252  const SimplifyQuery &Q);
253 
254 /// Given operands for an InsertValueInst, fold the result or return null.
255 Value *SimplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs,
256  const SimplifyQuery &Q);
257 
258 /// Given operands for an InsertElement, fold the result or return null.
260  const SimplifyQuery &Q);
261 
262 /// Given operands for an ExtractValueInst, fold the result or return null.
263 Value *SimplifyExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
264  const SimplifyQuery &Q);
265 
266 /// Given operands for an ExtractElementInst, fold the result or return null.
268  const SimplifyQuery &Q);
269 
270 /// Given operands for a CastInst, fold the result or return null.
271 Value *SimplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty,
272  const SimplifyQuery &Q);
273 
274 /// Given operands for a ShuffleVectorInst, fold the result or return null.
275 /// See class ShuffleVectorInst for a description of the mask representation.
276 Value *SimplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef<int> Mask,
277  Type *RetTy, const SimplifyQuery &Q);
278 
279 //=== Helper functions for higher up the class hierarchy.
280 
281 /// Given operands for a CmpInst, fold the result or return null.
282 Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
283  const SimplifyQuery &Q);
284 
285 /// Given operand for a UnaryOperator, fold the result or return null.
286 Value *SimplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q);
287 
288 /// Given operand for a UnaryOperator, fold the result or return null.
289 /// Try to use FastMathFlags when folding the result.
290 Value *SimplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF,
291  const SimplifyQuery &Q);
292 
293 /// Given operands for a BinaryOperator, fold the result or return null.
294 Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
295  const SimplifyQuery &Q);
296 
297 /// Given operands for a BinaryOperator, fold the result or return null.
298 /// Try to use FastMathFlags when folding the result.
299 Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, FastMathFlags FMF,
300  const SimplifyQuery &Q);
301 
302 /// Given a callsite, fold the result or return null.
303 Value *SimplifyCall(CallBase *Call, const SimplifyQuery &Q);
304 
305 /// Given an operand for a Freeze, see if we can fold the result.
306 /// If not, this returns null.
308 
309 /// See if we can compute a simplified version of this instruction. If not,
310 /// return null.
311 Value *SimplifyInstruction(Instruction *I, const SimplifyQuery &Q,
312  OptimizationRemarkEmitter *ORE = nullptr);
313 
314 /// Like \p SimplifyInstruction but the operands of \p I are replaced with
315 /// \p NewOps. Returns a simplified value, or null if none was found.
316 Value *
317 SimplifyInstructionWithOperands(Instruction *I, ArrayRef<Value *> NewOps,
318  const SimplifyQuery &Q,
319  OptimizationRemarkEmitter *ORE = nullptr);
320 
321 /// See if V simplifies when its operand Op is replaced with RepOp. If not,
322 /// return null.
323 /// AllowRefinement specifies whether the simplification can be a refinement
324 /// (e.g. 0 instead of poison), or whether it needs to be strictly identical.
326  const SimplifyQuery &Q, bool AllowRefinement);
327 
328 /// Replace all uses of 'I' with 'SimpleV' and simplify the uses recursively.
329 ///
330 /// This first performs a normal RAUW of I with SimpleV. It then recursively
331 /// attempts to simplify those users updated by the operation. The 'I'
332 /// instruction must not be equal to the simplified value 'SimpleV'.
333 /// If UnsimplifiedUsers is provided, instructions that could not be simplified
334 /// are added to it.
335 ///
336 /// The function returns true if any simplifications were performed.
338  Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI = nullptr,
339  const DominatorTree *DT = nullptr, AssumptionCache *AC = nullptr,
340  SmallSetVector<Instruction *, 8> *UnsimplifiedUsers = nullptr);
341 
342 // These helper functions return a SimplifyQuery structure that contains as
343 // many of the optional analysis we use as are currently valid. This is the
344 // strongly preferred way of constructing SimplifyQuery in passes.
345 const SimplifyQuery getBestSimplifyQuery(Pass &, Function &);
346 template <class T, class... TArgs>
347 const SimplifyQuery getBestSimplifyQuery(AnalysisManager<T, TArgs...> &,
348  Function &);
349 const SimplifyQuery getBestSimplifyQuery(LoopStandardAnalysisResults &,
350  const DataLayout &);
351 } // end namespace llvm
352 
353 #endif
llvm::SimplifyMulInst
Value * SimplifyMulInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a Mul, fold the result or return null.
Definition: InstructionSimplify.cpp:935
llvm::SimplifyExtractElementInst
Value * SimplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQuery &Q)
Given operands for an ExtractElementInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4566
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::SimplifyURemInst
Value * SimplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a URem, fold the result or return null.
Definition: InstructionSimplify.cpp:1223
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:1966
llvm::SimplifySubInst
Value * SimplifySubInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, const SimplifyQuery &Q)
Given operands for a Sub, fold the result or return null.
Definition: InstructionSimplify.cpp:870
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::SimplifyQuery
Definition: InstructionSimplify.h:94
llvm::SimplifyQuery::getWithoutUndef
SimplifyQuery getWithoutUndef() const
Definition: InstructionSimplify.h:126
llvm::Function
Definition: Function.h:61
llvm::SimplifyAndInst
Value * SimplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an And, fold the result or return null.
Definition: InstructionSimplify.cpp:2171
llvm::SimplifySelectInst
Value * SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, const SimplifyQuery &Q)
Given operands for a SelectInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4291
llvm::SimplifyFSubInst
Value * SimplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior=fp::ebIgnore, RoundingMode Rounding=RoundingMode::NearestTiesToEven)
Given operands for an FSub, fold the result or return null.
Definition: InstructionSimplify.cpp:5062
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:151
llvm::InstrInfoQuery::InstrInfoQuery
InstrInfoQuery()
Definition: InstructionSimplify.h:66
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::SimplifyUnOp
Value * SimplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q)
Given operand for a UnaryOperator, fold the result or return null.
Definition: InstructionSimplify.cpp:5207
llvm::LoopStandardAnalysisResults
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
Definition: LoopAnalysisManager.h:52
llvm::SimplifyFNegInst
Value * SimplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q)
Given operand for an FNeg, fold the result or return null.
Definition: InstructionSimplify.cpp:4843
llvm::SimplifyFreezeInst
Value * SimplifyFreezeInst(Value *Op, const SimplifyQuery &Q)
Given an operand for a Freeze, see if we can fold the result.
Definition: InstructionSimplify.cpp:6008
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::SimplifyCmpInst
Value * SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a CmpInst, fold the result or return null.
Definition: InstructionSimplify.cpp:5300
llvm::tgtok::FalseVal
@ FalseVal
Definition: TGLexer.h:61
Operator.h
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::SimplifyCastInst
Value * SimplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, const SimplifyQuery &Q)
Given operands for a CastInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4643
llvm::InstrInfoQuery::getMetadata
MDNode * getMetadata(const Instruction *I, unsigned KindID) const
Definition: InstructionSimplify.h:69
llvm::SimplifyQuery::isUndefValue
bool isUndefValue(Value *V) const
If CanUseUndef is true, returns whether V is undef.
Definition: InstructionSimplify.h:134
Instruction.h
llvm::SimplifyQuery::AC
AssumptionCache * AC
Definition: InstructionSimplify.h:98
llvm::SimplifySDivInst
Value * SimplifySDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an SDiv, fold the result or return null.
Definition: InstructionSimplify.cpp:1180
llvm::SimplifyShlInst
Value * SimplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, const SimplifyQuery &Q)
Given operands for a Shl, fold the result or return null.
Definition: InstructionSimplify.cpp:1381
llvm::SimplifyCall
Value * SimplifyCall(CallBase *Call, const SimplifyQuery &Q)
Given a callsite, fold the result or return null.
Definition: InstructionSimplify.cpp:5976
llvm::PatternMatch::match
bool match(Val *V, const Pattern &P)
Definition: PatternMatch.h:49
llvm::RoundingMode
RoundingMode
Rounding mode.
Definition: FloatingPointMode.h:34
llvm::SimplifyICmpInst
Value * SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an ICmpInst, fold the result or return null.
Definition: InstructionSimplify.cpp:3682
llvm::SimplifyQuery::DL
const DataLayout & DL
Definition: InstructionSimplify.h:95
llvm::SimplifyAShrInst
Value * SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q)
Given operands for a AShr, fold the result or return nulll.
Definition: InstructionSimplify.cpp:1450
llvm::Instruction
Definition: Instruction.h:45
llvm::SimplifyQuery::IIQ
const InstrInfoQuery IIQ
Definition: InstructionSimplify.h:104
llvm::SimplifyInstruction
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
Definition: InstructionSimplify.cpp:6246
PatternMatch.h
llvm::SimplifySRemInst
Value * SimplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an SRem, fold the result or return null.
Definition: InstructionSimplify.cpp:1212
llvm::SimplifyGEPInst
Value * SimplifyGEPInst(Type *SrcTy, ArrayRef< Value * > Ops, const SimplifyQuery &Q)
Given operands for a GetElementPtrInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4422
llvm::SimplifyFAddInst
Value * SimplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior=fp::ebIgnore, RoundingMode Rounding=RoundingMode::NearestTiesToEven)
Given operands for an FAdd, fold the result or return null.
Definition: InstructionSimplify.cpp:5054
llvm::InstrInfoQuery::hasNoUnsignedWrap
bool hasNoUnsignedWrap(const InstT *Op) const
Definition: InstructionSimplify.h:75
llvm::SimplifyFMulInst
Value * SimplifyFMulInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior=fp::ebIgnore, RoundingMode Rounding=RoundingMode::NearestTiesToEven)
Given operands for an FMul, fold the result or return null.
Definition: InstructionSimplify.cpp:5070
llvm::InstrInfoQuery::isExact
bool isExact(const BinaryOperator *Op) const
Definition: InstructionSimplify.h:87
llvm::SimplifyQuery::SimplifyQuery
SimplifyQuery(const DataLayout &DL, const TargetLibraryInfo *TLI, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, const Instruction *CXTI=nullptr, bool UseInstrInfo=true, bool CanUseUndef=true)
Definition: InstructionSimplify.h:114
llvm::SimplifyBinOp
Value * SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a BinaryOperator, fold the result or return null.
Definition: InstructionSimplify.cpp:5282
llvm::SimplifyQuery::TLI
const TargetLibraryInfo * TLI
Definition: InstructionSimplify.h:96
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::SimplifyShuffleVectorInst
Value * SimplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef< int > Mask, Type *RetTy, const SimplifyQuery &Q)
Given operands for a ShuffleVectorInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4815
llvm::SimplifyQuery::DT
const DominatorTree * DT
Definition: InstructionSimplify.h:97
llvm::SimplifyFMAFMul
Value * SimplifyFMAFMul(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior=fp::ebIgnore, RoundingMode Rounding=RoundingMode::NearestTiesToEven)
Given operands for the multiplication of a FMA, fold the result or return null.
Definition: InstructionSimplify.cpp:5078
llvm::replaceAndRecursivelySimplify
bool replaceAndRecursivelySimplify(Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, SmallSetVector< Instruction *, 8 > *UnsimplifiedUsers=nullptr)
Replace all uses of 'I' with 'SimpleV' and simplify the uses recursively.
Definition: InstructionSimplify.cpp:6324
llvm::SimplifyQuery::getWithInstruction
SimplifyQuery getWithInstruction(Instruction *I) const
Definition: InstructionSimplify.h:121
llvm::MDNode
Metadata node.
Definition: Metadata.h:897
llvm::SimplifyFCmpInst
Value * SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q)
Given operands for an FCmpInst, fold the result or return null.
Definition: InstructionSimplify.cpp:3891
llvm::SimplifyFDivInst
Value * SimplifyFDivInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior=fp::ebIgnore, RoundingMode Rounding=RoundingMode::NearestTiesToEven)
Given operands for an FDiv, fold the result or return null.
Definition: InstructionSimplify.cpp:5133
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::InstrInfoQuery
InstrInfoQuery provides an interface to query additional information for instructions like metadata o...
Definition: InstructionSimplify.h:64
llvm::SimplifyLShrInst
Value * SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q)
Given operands for a LShr, fold the result or return null.
Definition: InstructionSimplify.cpp:1419
llvm::BinaryOperator
Definition: InstrTypes.h:189
llvm::OptimizationRemarkEmitter
The optimization diagnostic interface.
Definition: OptimizationRemarkEmitter.h:33
llvm::SimplifyInstructionWithOperands
Value * SimplifyInstructionWithOperands(Instruction *I, ArrayRef< Value * > NewOps, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
Like SimplifyInstruction but the operands of I are replaced with NewOps.
Definition: InstructionSimplify.cpp:6237
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:179
llvm::SimplifyInsertElementInst
Value * SimplifyInsertElementInst(Value *Vec, Value *Elt, Value *Idx, const SimplifyQuery &Q)
Given operands for an InsertElement, fold the result or return null.
Definition: InstructionSimplify.cpp:4462
llvm::PatternMatch::m_Undef
auto m_Undef()
Match an arbitrary undef constant.
Definition: PatternMatch.h:136
llvm::AssumptionCache
A cache of @llvm.assume calls within a function.
Definition: AssumptionCache.h:41
llvm::SimplifyExtractValueInst
Value * SimplifyExtractValueInst(Value *Agg, ArrayRef< unsigned > Idxs, const SimplifyQuery &Q)
Given operands for an ExtractValueInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4522
llvm::SimplifyInsertValueInst
Value * SimplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const SimplifyQuery &Q)
Given operands for an InsertValueInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4456
llvm::simplifyWithOpReplaced
Value * simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp, const SimplifyQuery &Q, bool AllowRefinement)
See if V simplifies when its operand Op is replaced with RepOp.
Definition: InstructionSimplify.cpp:4011
llvm::getBestSimplifyQuery
const SimplifyQuery getBestSimplifyQuery(Pass &, Function &)
Definition: InstructionSimplify.cpp:6335
llvm::SimplifyQuery::CxtI
const Instruction * CxtI
Definition: InstructionSimplify.h:99
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::SimplifyFRemInst
Value * SimplifyFRemInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior=fp::ebIgnore, RoundingMode Rounding=RoundingMode::NearestTiesToEven)
Given operands for an FRem, fold the result or return null.
Definition: InstructionSimplify.cpp:5171
llvm::SimplifyQuery::CanUseUndef
bool CanUseUndef
Controls whether simplifications are allowed to constrain the range of possible values for uses of un...
Definition: InstructionSimplify.h:109
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition: TargetLibraryInfo.h:219
llvm::InstrInfoQuery::UseInstrInfo
bool UseInstrInfo
Definition: InstructionSimplify.h:67
llvm::fp::ebIgnore
@ ebIgnore
This corresponds to "fpexcept.ignore".
Definition: FPEnv.h:32
llvm::SimplifyUDivInst
Value * SimplifyUDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a UDiv, fold the result or return null.
Definition: InstructionSimplify.cpp:1191
Predicate
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
llvm::fp::ExceptionBehavior
ExceptionBehavior
Exception behavior used for floating point operations.
Definition: FPEnv.h:31
llvm::SimplifyOrInst
Value * SimplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an Or, fold the result or return null.
Definition: InstructionSimplify.cpp:2351
llvm::SimplifyQuery::SimplifyQuery
SimplifyQuery(const DataLayout &DL, const Instruction *CXTI=nullptr)
Definition: InstructionSimplify.h:111
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1161
llvm::SmallSetVector
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:307
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::SimplifyAddInst
Value * SimplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, const SimplifyQuery &Q)
Given operands for an Add, fold the result or return null.
Definition: InstructionSimplify.cpp:682
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1815
llvm::tgtok::TrueVal
@ TrueVal
Definition: TGLexer.h:61
llvm::InstrInfoQuery::InstrInfoQuery
InstrInfoQuery(bool UMD)
Definition: InstructionSimplify.h:65
llvm::RoundingMode::NearestTiesToEven
@ NearestTiesToEven
roundTiesToEven.
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::SimplifyXorInst
Value * SimplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an Xor, fold the result or return null.
Definition: InstructionSimplify.cpp:2399
llvm::InstrInfoQuery::hasNoSignedWrap
bool hasNoSignedWrap(const InstT *Op) const
Definition: InstructionSimplify.h:81
llvm::AArch64::Rounding
Rounding
Possible values of current rounding mode, which is specified in bits 23:22 of FPCR.
Definition: AArch64ISelLowering.h:469