LLVM 17.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
39
40namespace llvm {
41
42template <typename T, typename... TArgs> class AnalysisManager;
43template <class T> class ArrayRef;
44class AssumptionCache;
45class BinaryOperator;
46class CallBase;
47class DataLayout;
48class DominatorTree;
49class Function;
50class Instruction;
51struct LoopStandardAnalysisResults;
52class MDNode;
53class Pass;
54template <class T, unsigned n> class SmallSetVector;
55class TargetLibraryInfo;
56class Type;
57class Value;
58
59/// InstrInfoQuery provides an interface to query additional information for
60/// instructions like metadata or keywords like nsw, which provides conservative
61/// results if the users specified it is safe to use.
63 InstrInfoQuery(bool UMD) : UseInstrInfo(UMD) {}
64 InstrInfoQuery() = default;
65 bool UseInstrInfo = true;
66
67 MDNode *getMetadata(const Instruction *I, unsigned KindID) const {
68 if (UseInstrInfo)
69 return I->getMetadata(KindID);
70 return nullptr;
71 }
72
73 template <class InstT> bool hasNoUnsignedWrap(const InstT *Op) const {
74 if (UseInstrInfo)
75 return Op->hasNoUnsignedWrap();
76 return false;
77 }
78
79 template <class InstT> bool hasNoSignedWrap(const InstT *Op) const {
80 if (UseInstrInfo)
81 return Op->hasNoSignedWrap();
82 return false;
83 }
84
85 bool isExact(const BinaryOperator *Op) const {
86 if (UseInstrInfo && isa<PossiblyExactOperator>(Op))
87 return cast<PossiblyExactOperator>(Op)->isExact();
88 return false;
89 }
90};
91
93 const DataLayout &DL;
94 const TargetLibraryInfo *TLI = nullptr;
95 const DominatorTree *DT = nullptr;
96 AssumptionCache *AC = nullptr;
97 const Instruction *CxtI = nullptr;
98
99 // Wrapper to query additional information for instructions like metadata or
100 // keywords like nsw, which provides conservative results if those cannot
101 // be safely used.
103
104 /// Controls whether simplifications are allowed to constrain the range of
105 /// possible values for uses of undef. If it is false, simplifications are not
106 /// allowed to assume a particular value for a use of undef for example.
107 bool CanUseUndef = true;
108
109 SimplifyQuery(const DataLayout &DL, const Instruction *CXTI = nullptr)
110 : DL(DL), CxtI(CXTI) {}
111
113 const DominatorTree *DT = nullptr,
114 AssumptionCache *AC = nullptr,
115 const Instruction *CXTI = nullptr, bool UseInstrInfo = true,
116 bool CanUseUndef = true)
117 : DL(DL), TLI(TLI), DT(DT), AC(AC), CxtI(CXTI), IIQ(UseInstrInfo),
120 SimplifyQuery Copy(*this);
121 Copy.CxtI = I;
122 return Copy;
123 }
125 SimplifyQuery Copy(*this);
126 Copy.CanUseUndef = false;
127 return Copy;
128 }
129
130 /// If CanUseUndef is true, returns whether \p V is undef.
131 /// Otherwise always return false.
132 bool isUndefValue(Value *V) const {
133 if (!CanUseUndef)
134 return false;
135
136 using namespace PatternMatch;
137 return match(V, m_Undef());
138 }
139};
140
141// NOTE: the explicit multiple argument versions of these functions are
142// deprecated.
143// Please use the SimplifyQuery versions in new code.
144
145/// Given operands for an Add, fold the result or return null.
146Value *simplifyAddInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW,
147 const SimplifyQuery &Q);
148
149/// Given operands for a Sub, fold the result or return null.
150Value *simplifySubInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW,
151 const SimplifyQuery &Q);
152
153/// Given operands for a Mul, fold the result or return null.
154Value *simplifyMulInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW,
155 const SimplifyQuery &Q);
156
157/// Given operands for an SDiv, fold the result or return null.
158Value *simplifySDivInst(Value *LHS, Value *RHS, bool IsExact,
159 const SimplifyQuery &Q);
160
161/// Given operands for a UDiv, fold the result or return null.
162Value *simplifyUDivInst(Value *LHS, Value *RHS, bool IsExact,
163 const SimplifyQuery &Q);
164
165/// Given operands for an SRem, fold the result or return null.
166Value *simplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
167
168/// Given operands for a URem, fold the result or return null.
169Value *simplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
170
171/// Given operand for an FNeg, fold the result or return null.
172Value *simplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q);
173
174
175/// Given operands for an FAdd, fold the result or return null.
176Value *
177simplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF,
178 const SimplifyQuery &Q,
181
182/// Given operands for an FSub, fold the result or return null.
183Value *
184simplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF,
185 const SimplifyQuery &Q,
188
189/// Given operands for an FMul, fold the result or return null.
190Value *
191simplifyFMulInst(Value *LHS, Value *RHS, FastMathFlags FMF,
192 const SimplifyQuery &Q,
195
196/// Given operands for the multiplication of a FMA, fold the result or return
197/// null. In contrast to simplifyFMulInst, this function will not perform
198/// simplifications whose unrounded results differ when rounded to the argument
199/// type.
200Value *simplifyFMAFMul(Value *LHS, Value *RHS, FastMathFlags FMF,
201 const SimplifyQuery &Q,
204
205/// Given operands for an FDiv, fold the result or return null.
206Value *
207simplifyFDivInst(Value *LHS, Value *RHS, FastMathFlags FMF,
208 const SimplifyQuery &Q,
211
212/// Given operands for an FRem, fold the result or return null.
213Value *
214simplifyFRemInst(Value *LHS, Value *RHS, FastMathFlags FMF,
215 const SimplifyQuery &Q,
218
219/// Given operands for a Shl, fold the result or return null.
220Value *simplifyShlInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
221 const SimplifyQuery &Q);
222
223/// Given operands for a LShr, fold the result or return null.
224Value *simplifyLShrInst(Value *Op0, Value *Op1, bool IsExact,
225 const SimplifyQuery &Q);
226
227/// Given operands for a AShr, fold the result or return nulll.
228Value *simplifyAShrInst(Value *Op0, Value *Op1, bool IsExact,
229 const SimplifyQuery &Q);
230
231/// Given operands for an And, fold the result or return null.
232Value *simplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
233
234/// Given operands for an Or, fold the result or return null.
235Value *simplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
236
237/// Given operands for an Xor, fold the result or return null.
238Value *simplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
239
240/// Given operands for an ICmpInst, fold the result or return null.
241Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
242 const SimplifyQuery &Q);
243
244/// Given operands for an FCmpInst, fold the result or return null.
245Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
246 FastMathFlags FMF, const SimplifyQuery &Q);
247
248/// Given operands for a SelectInst, fold the result or return null.
249Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
250 const SimplifyQuery &Q);
251
252/// Given operands for a GetElementPtrInst, fold the result or return null.
253Value *simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef<Value *> Indices,
254 bool InBounds, const SimplifyQuery &Q);
255
256/// Given operands for an InsertValueInst, fold the result or return null.
257Value *simplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs,
258 const SimplifyQuery &Q);
259
260/// Given operands for an InsertElement, fold the result or return null.
261Value *simplifyInsertElementInst(Value *Vec, Value *Elt, Value *Idx,
262 const SimplifyQuery &Q);
263
264/// Given operands for an ExtractValueInst, fold the result or return null.
265Value *simplifyExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
266 const SimplifyQuery &Q);
267
268/// Given operands for an ExtractElementInst, fold the result or return null.
269Value *simplifyExtractElementInst(Value *Vec, Value *Idx,
270 const SimplifyQuery &Q);
271
272/// Given operands for a CastInst, fold the result or return null.
273Value *simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty,
274 const SimplifyQuery &Q);
275
276/// Given operands for a ShuffleVectorInst, fold the result or return null.
277/// See class ShuffleVectorInst for a description of the mask representation.
278Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef<int> Mask,
279 Type *RetTy, const SimplifyQuery &Q);
280
281//=== Helper functions for higher up the class hierarchy.
282
283/// Given operands for a CmpInst, fold the result or return null.
284Value *simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
285 const SimplifyQuery &Q);
286
287/// Given operand for a UnaryOperator, fold the result or return null.
288Value *simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q);
289
290/// Given operand for a UnaryOperator, fold the result or return null.
291/// Try to use FastMathFlags when folding the result.
292Value *simplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF,
293 const SimplifyQuery &Q);
294
295/// Given operands for a BinaryOperator, fold the result or return null.
296Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
297 const SimplifyQuery &Q);
298
299/// Given operands for a BinaryOperator, fold the result or return null.
300/// Try to use FastMathFlags when folding the result.
301Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, FastMathFlags FMF,
302 const SimplifyQuery &Q);
303
304/// Given a callsite, callee, and arguments, fold the result or return null.
305Value *simplifyCall(CallBase *Call, Value *Callee, ArrayRef<Value *> Args,
306 const SimplifyQuery &Q);
307
308/// Given a constrained FP intrinsic call, tries to compute its simplified
309/// version. Returns a simplified result or null.
310///
311/// This function provides an additional contract: it guarantees that if
312/// simplification succeeds that the intrinsic is side effect free. As a result,
313/// successful simplification can be used to delete the intrinsic not just
314/// replace its result.
315Value *simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q);
316
317/// Given an operand for a Freeze, see if we can fold the result.
318/// If not, this returns null.
319Value *simplifyFreezeInst(Value *Op, const SimplifyQuery &Q);
320
321/// Given a load instruction and its pointer operand, fold the result or return
322/// null.
323Value *simplifyLoadInst(LoadInst *LI, Value *PtrOp, const SimplifyQuery &Q);
324
325/// See if we can compute a simplified version of this instruction. If not,
326/// return null.
327Value *simplifyInstruction(Instruction *I, const SimplifyQuery &Q);
328
329/// Like \p simplifyInstruction but the operands of \p I are replaced with
330/// \p NewOps. Returns a simplified value, or null if none was found.
331Value *
332simplifyInstructionWithOperands(Instruction *I, ArrayRef<Value *> NewOps,
333 const SimplifyQuery &Q);
334
335/// See if V simplifies when its operand Op is replaced with RepOp. If not,
336/// return null.
337/// AllowRefinement specifies whether the simplification can be a refinement
338/// (e.g. 0 instead of poison), or whether it needs to be strictly identical.
339/// Op and RepOp can be assumed to not be poison when determining refinement.
340Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
341 const SimplifyQuery &Q, bool AllowRefinement);
342
343/// Replace all uses of 'I' with 'SimpleV' and simplify the uses recursively.
344///
345/// This first performs a normal RAUW of I with SimpleV. It then recursively
346/// attempts to simplify those users updated by the operation. The 'I'
347/// instruction must not be equal to the simplified value 'SimpleV'.
348/// If UnsimplifiedUsers is provided, instructions that could not be simplified
349/// are added to it.
350///
351/// The function returns true if any simplifications were performed.
353 Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI = nullptr,
354 const DominatorTree *DT = nullptr, AssumptionCache *AC = nullptr,
355 SmallSetVector<Instruction *, 8> *UnsimplifiedUsers = nullptr);
356
357// These helper functions return a SimplifyQuery structure that contains as
358// many of the optional analysis we use as are currently valid. This is the
359// strongly preferred way of constructing SimplifyQuery in passes.
360const SimplifyQuery getBestSimplifyQuery(Pass &, Function &);
361template <class T, class... TArgs>
362const SimplifyQuery getBestSimplifyQuery(AnalysisManager<T, TArgs...> &,
363 Function &);
364const SimplifyQuery getBestSimplifyQuery(LoopStandardAnalysisResults &,
365 const DataLayout &);
366} // end namespace llvm
367
368#endif
amdgpu Simplify well known AMD library false FunctionCallee Callee
SmallVector< MachineOperand, 4 > Cond
RelocType Type
Definition: COFFYAML.cpp:391
return RetTy
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
print lazy value Lazy Value Info Printer Pass
#define I(x, y, z)
Definition: MD5.cpp:58
#define T
Value * RHS
Value * LHS
A cache of @llvm.assume calls within a function.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
Metadata node.
Definition: Metadata.h:950
Provides information about what library functions are available for the current target.
LLVM Value Representation.
Definition: Value.h:74
bool match(Val *V, const Pattern &P)
Definition: PatternMatch.h:49
auto m_Undef()
Match an arbitrary undef constant.
Definition: PatternMatch.h:136
ExceptionBehavior
Exception behavior used for floating point operations.
Definition: FPEnv.h:38
@ ebIgnore
This corresponds to "fpexcept.ignore".
Definition: FPEnv.h:39
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Value * simplifyAShrInst(Value *Op0, Value *Op1, bool IsExact, const SimplifyQuery &Q)
Given operands for a AShr, fold the result or return nulll.
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.
Value * simplifyFreezeInst(Value *Op, const SimplifyQuery &Q)
Given an operand for a Freeze, see if we can fold the result.
Value * simplifySDivInst(Value *LHS, Value *RHS, bool IsExact, const SimplifyQuery &Q)
Given operands for an SDiv, fold the result or return null.
Value * simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q)
Given operand for a UnaryOperator, fold the result or return null.
Value * simplifyMulInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW, const SimplifyQuery &Q)
Given operands for a Mul, fold the result or return null.
Value * simplifyInstructionWithOperands(Instruction *I, ArrayRef< Value * > NewOps, const SimplifyQuery &Q)
Like simplifyInstruction but the operands of I are replaced with NewOps.
Value * simplifyCall(CallBase *Call, Value *Callee, ArrayRef< Value * > Args, const SimplifyQuery &Q)
Given a callsite, callee, and arguments, fold the result or return null.
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.
Value * simplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an Or, fold the result or return null.
Value * simplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an Xor, fold the result or return null.
Value * simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, const SimplifyQuery &Q)
Given operands for a CastInst, fold the result or return null.
Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q)
See if we can compute a simplified version of this instruction.
Value * simplifySubInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW, const SimplifyQuery &Q)
Given operands for a Sub, fold the result or return null.
Value * simplifyAddInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW, const SimplifyQuery &Q)
Given operands for an Add, fold the result or return null.
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.
Value * simplifyShlInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, const SimplifyQuery &Q)
Given operands for a Shl, fold the result or return null.
Value * simplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q)
Given operand for an FNeg, fold the result or return null.
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.
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.
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.
Value * simplifyLShrInst(Value *Op0, Value *Op1, bool IsExact, const SimplifyQuery &Q)
Given operands for a LShr, fold the result or return null.
Value * simplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an And, fold the result or return null.
Value * simplifyExtractValueInst(Value *Agg, ArrayRef< unsigned > Idxs, const SimplifyQuery &Q)
Given operands for an ExtractValueInst, fold the result or return null.
Value * simplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const SimplifyQuery &Q)
Given operands for an InsertValueInst, fold the result or return null.
Value * simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an ICmpInst, fold the result or return null.
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.
Value * simplifyLoadInst(LoadInst *LI, Value *PtrOp, const SimplifyQuery &Q)
Given a load instruction and its pointer operand, fold the result or return null.
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.
Value * simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q)
Given a constrained FP intrinsic call, tries to compute its simplified version.
Value * simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a BinaryOperator, fold the result or return null.
Value * simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a CmpInst, fold the result or return null.
Value * simplifyUDivInst(Value *LHS, Value *RHS, bool IsExact, const SimplifyQuery &Q)
Given operands for a UDiv, fold the result or return null.
RoundingMode
Rounding mode.
@ NearestTiesToEven
roundTiesToEven.
ArrayRef(const T &OneElt) -> ArrayRef< T >
Value * simplifyInsertElementInst(Value *Vec, Value *Elt, Value *Idx, const SimplifyQuery &Q)
Given operands for an InsertElement, fold the result or return null.
Value * simplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for an SRem, fold the result or return null.
const SimplifyQuery getBestSimplifyQuery(Pass &, Function &)
Value * simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q)
Given operands for an FCmpInst, fold the result or return null.
Value * simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef< Value * > Indices, bool InBounds, const SimplifyQuery &Q)
Given operands for a GetElementPtrInst, fold the result or return null.
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.
Value * simplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q)
Given operands for a URem, fold the result or return null.
Value * simplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQuery &Q)
Given operands for an ExtractElementInst, fold the result or return null.
Value * simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, const SimplifyQuery &Q)
Given operands for a SelectInst, fold the result or return null.
InstrInfoQuery provides an interface to query additional information for instructions like metadata o...
bool isExact(const BinaryOperator *Op) const
MDNode * getMetadata(const Instruction *I, unsigned KindID) const
bool hasNoSignedWrap(const InstT *Op) const
InstrInfoQuery()=default
bool hasNoUnsignedWrap(const InstT *Op) const
const DataLayout & DL
const Instruction * CxtI
SimplifyQuery(const DataLayout &DL, const Instruction *CXTI=nullptr)
bool CanUseUndef
Controls whether simplifications are allowed to constrain the range of possible values for uses of un...
const DominatorTree * DT
bool isUndefValue(Value *V) const
If CanUseUndef is true, returns whether V is undef.
AssumptionCache * AC
SimplifyQuery getWithInstruction(Instruction *I) const
const TargetLibraryInfo * TLI
SimplifyQuery(const DataLayout &DL, const TargetLibraryInfo *TLI, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, const Instruction *CXTI=nullptr, bool UseInstrInfo=true, bool CanUseUndef=true)
SimplifyQuery getWithoutUndef() const
const InstrInfoQuery IIQ