Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
ValueTracking.h
Go to the documentation of this file.
1//===- llvm/Analysis/ValueTracking.h - Walk computations --------*- 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 contains routines that help analyze properties that chains of
10// computations have.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ANALYSIS_VALUETRACKING_H
15#define LLVM_ANALYSIS_VALUETRACKING_H
16
17#include "llvm/Analysis/SimplifyQuery.h"
18#include "llvm/Analysis/WithCache.h"
19#include "llvm/IR/Constants.h"
20#include "llvm/IR/DataLayout.h"
21#include "llvm/IR/FMF.h"
22#include "llvm/IR/Instructions.h"
23#include "llvm/IR/InstrTypes.h"
24#include "llvm/IR/Intrinsics.h"
25#include <cassert>
26#include <cstdint>
27
28namespacellvm {
29
30classOperator;
31classAddOperator;
32classAssumptionCache;
33classDominatorTree;
34classGEPOperator;
35classWithOverflowInst;
36structKnownBits;
37classLoop;
38classLoopInfo;
39classMDNode;
40classStringRef;
41classTargetLibraryInfo;
42template <typename T>classArrayRef;
43
44constexprunsignedMaxAnalysisRecursionDepth = 6;
45
46/// Determine which bits of V are known to be either zero or one and return
47/// them in the KnownZero/KnownOne bit sets.
48///
49/// This function is defined on values with integer type, values with pointer
50/// type, and vectors of integers. In the case
51/// where V is a vector, the known zero and known one values are the
52/// same width as the vector element, and the bit is set only if it is true
53/// for all of the elements in the vector.
54voidcomputeKnownBits(constValue *V,KnownBits &Known,constDataLayout &DL,
55unsignedDepth = 0,AssumptionCache *AC =nullptr,
56constInstruction *CxtI =nullptr,
57constDominatorTree *DT =nullptr,
58bool UseInstrInfo =true);
59
60/// Returns the known bits rather than passing by reference.
61KnownBitscomputeKnownBits(constValue *V,constDataLayout &DL,
62unsignedDepth = 0,AssumptionCache *AC =nullptr,
63constInstruction *CxtI =nullptr,
64constDominatorTree *DT =nullptr,
65bool UseInstrInfo =true);
66
67/// Returns the known bits rather than passing by reference.
68KnownBitscomputeKnownBits(constValue *V,constAPInt &DemandedElts,
69constDataLayout &DL,unsignedDepth = 0,
70AssumptionCache *AC =nullptr,
71constInstruction *CxtI =nullptr,
72constDominatorTree *DT =nullptr,
73bool UseInstrInfo =true);
74
75KnownBitscomputeKnownBits(constValue *V,constAPInt &DemandedElts,
76unsignedDepth,constSimplifyQuery &Q);
77
78KnownBitscomputeKnownBits(constValue *V,unsignedDepth,
79constSimplifyQuery &Q);
80
81voidcomputeKnownBits(constValue *V,KnownBits &Known,unsignedDepth,
82constSimplifyQuery &Q);
83
84/// Compute known bits from the range metadata.
85/// \p KnownZero the set of bits that are known to be zero
86/// \p KnownOne the set of bits that are known to be one
87voidcomputeKnownBitsFromRangeMetadata(constMDNode &Ranges,KnownBits &Known);
88
89/// Merge bits known from context-dependent facts into Known.
90voidcomputeKnownBitsFromContext(constValue *V,KnownBits &Known,
91unsignedDepth,constSimplifyQuery &Q);
92
93/// Using KnownBits LHS/RHS produce the known bits for logic op (and/xor/or).
94KnownBitsanalyzeKnownBitsFromAndXorOr(constOperator *I,
95constKnownBits &KnownLHS,
96constKnownBits &KnownRHS,
97unsignedDepth,constSimplifyQuery &SQ);
98
99/// Adjust \p Known for the given select \p Arm to include information from the
100/// select \p Cond.
101voidadjustKnownBitsForSelectArm(KnownBits &Known,Value *Cond,Value *Arm,
102bool Invert,unsignedDepth,
103constSimplifyQuery &Q);
104
105/// Return true if LHS and RHS have no common bits set.
106boolhaveNoCommonBitsSet(constWithCache<const Value *> &LHSCache,
107constWithCache<const Value *> &RHSCache,
108constSimplifyQuery &SQ);
109
110/// Return true if the given value is known to have exactly one bit set when
111/// defined. For vectors return true if every element is known to be a power
112/// of two when defined. Supports values with integer or pointer type and
113/// vectors of integers. If 'OrZero' is set, then return true if the given
114/// value is either a power of two or zero.
115boolisKnownToBeAPowerOfTwo(constValue *V,constDataLayout &DL,
116bool OrZero =false,unsignedDepth = 0,
117AssumptionCache *AC =nullptr,
118constInstruction *CxtI =nullptr,
119constDominatorTree *DT =nullptr,
120bool UseInstrInfo =true);
121
122boolisKnownToBeAPowerOfTwo(constValue *V,bool OrZero,unsignedDepth,
123constSimplifyQuery &Q);
124
125boolisOnlyUsedInZeroComparison(constInstruction *CxtI);
126
127boolisOnlyUsedInZeroEqualityComparison(constInstruction *CxtI);
128
129/// Return true if the given value is known to be non-zero when defined. For
130/// vectors, return true if every element is known to be non-zero when
131/// defined. For pointers, if the context instruction and dominator tree are
132/// specified, perform context-sensitive analysis and return true if the
133/// pointer couldn't possibly be null at the specified instruction.
134/// Supports values with integer or pointer type and vectors of integers.
135boolisKnownNonZero(constValue *V,constSimplifyQuery &Q,unsignedDepth = 0);
136
137/// Return true if the two given values are negation.
138/// Currently can recoginze Value pair:
139/// 1: <X, Y> if X = sub (0, Y) or Y = sub (0, X)
140/// 2: <X, Y> if X = sub (A, B) and Y = sub (B, A)
141boolisKnownNegation(constValue *X,constValue *Y,bool NeedNSW =false,
142bool AllowPoison =true);
143
144/// Return true iff:
145/// 1. X is poison implies Y is poison.
146/// 2. X is true implies Y is false.
147/// 3. X is false implies Y is true.
148/// Otherwise, return false.
149boolisKnownInversion(constValue *X,constValue *Y);
150
151/// Returns true if the give value is known to be non-negative.
152boolisKnownNonNegative(constValue *V,constSimplifyQuery &SQ,
153unsignedDepth = 0);
154
155/// Returns true if the given value is known be positive (i.e. non-negative
156/// and non-zero).
157boolisKnownPositive(constValue *V,constSimplifyQuery &SQ,
158unsignedDepth = 0);
159
160/// Returns true if the given value is known be negative (i.e. non-positive
161/// and non-zero).
162boolisKnownNegative(constValue *V,constSimplifyQuery &SQ,
163unsignedDepth = 0);
164
165/// Return true if the given values are known to be non-equal when defined.
166/// Supports scalar integer types only.
167boolisKnownNonEqual(constValue *V1,constValue *V2,constDataLayout &DL,
168AssumptionCache *AC =nullptr,
169constInstruction *CxtI =nullptr,
170constDominatorTree *DT =nullptr,
171bool UseInstrInfo =true);
172
173/// Return true if 'V & Mask' is known to be zero. We use this predicate to
174/// simplify operations downstream. Mask is known to be zero for bits that V
175/// cannot have.
176///
177/// This function is defined on values with integer type, values with pointer
178/// type, and vectors of integers. In the case
179/// where V is a vector, the mask, known zero, and known one values are the
180/// same width as the vector element, and the bit is set only if it is true
181/// for all of the elements in the vector.
182boolMaskedValueIsZero(constValue *V,constAPInt &Mask,
183constSimplifyQuery &SQ,unsignedDepth = 0);
184
185/// Return the number of times the sign bit of the register is replicated into
186/// the other bits. We know that at least 1 bit is always equal to the sign
187/// bit (itself), but other cases can give us information. For example,
188/// immediately after an "ashr X, 2", we know that the top 3 bits are all
189/// equal to each other, so we return 3. For vectors, return the number of
190/// sign bits for the vector element with the mininum number of known sign
191/// bits.
192unsignedComputeNumSignBits(constValue *Op,constDataLayout &DL,
193unsignedDepth = 0,AssumptionCache *AC =nullptr,
194constInstruction *CxtI =nullptr,
195constDominatorTree *DT =nullptr,
196bool UseInstrInfo =true);
197
198/// Get the upper bound on bit size for this Value \p Op as a signed integer.
199/// i.e. x == sext(trunc(x to MaxSignificantBits) to bitwidth(x)).
200/// Similar to the APInt::getSignificantBits function.
201unsignedComputeMaxSignificantBits(constValue *Op,constDataLayout &DL,
202unsignedDepth = 0,
203AssumptionCache *AC =nullptr,
204constInstruction *CxtI =nullptr,
205constDominatorTree *DT =nullptr);
206
207/// Map a call instruction to an intrinsic ID. Libcalls which have equivalent
208/// intrinsics are treated as-if they were intrinsics.
209Intrinsic::IDgetIntrinsicForCallSite(constCallBase &CB,
210constTargetLibraryInfo *TLI);
211
212/// Given an exploded icmp instruction, return true if the comparison only
213/// checks the sign bit. If it only checks the sign bit, set TrueIfSigned if
214/// the result of the comparison is true when the input value is signed.
215boolisSignBitCheck(ICmpInst::Predicate Pred,constAPInt &RHS,
216bool &TrueIfSigned);
217
218/// Returns a pair of values, which if passed to llvm.is.fpclass, returns the
219/// same result as an fcmp with the given operands.
220///
221/// If \p LookThroughSrc is true, consider the input value when computing the
222/// mask.
223///
224/// If \p LookThroughSrc is false, ignore the source value (i.e. the first pair
225/// element will always be LHS.
226std::pair<Value *, FPClassTest>fcmpToClassTest(CmpInst::Predicate Pred,
227constFunction &F,Value *LHS,
228Value *RHS,
229bool LookThroughSrc =true);
230std::pair<Value *, FPClassTest>fcmpToClassTest(CmpInst::Predicate Pred,
231constFunction &F,Value *LHS,
232constAPFloat *ConstRHS,
233bool LookThroughSrc =true);
234
235/// Compute the possible floating-point classes that \p LHS could be based on
236/// fcmp \Pred \p LHS, \p RHS.
237///
238/// \returns { TestedValue, ClassesIfTrue, ClassesIfFalse }
239///
240/// If the compare returns an exact class test, ClassesIfTrue == ~ClassesIfFalse
241///
242/// This is a less exact version of fcmpToClassTest (e.g. fcmpToClassTest will
243/// only succeed for a test of x > 0 implies positive, but not x > 1).
244///
245/// If \p LookThroughSrc is true, consider the input value when computing the
246/// mask. This may look through sign bit operations.
247///
248/// If \p LookThroughSrc is false, ignore the source value (i.e. the first pair
249/// element will always be LHS.
250///
251std::tuple<Value *, FPClassTest, FPClassTest>
252fcmpImpliesClass(CmpInst::Predicate Pred,constFunction &F,Value *LHS,
253Value *RHS,bool LookThroughSrc =true);
254std::tuple<Value *, FPClassTest, FPClassTest>
255fcmpImpliesClass(CmpInst::Predicate Pred,constFunction &F,Value *LHS,
256FPClassTestRHS,bool LookThroughSrc =true);
257std::tuple<Value *, FPClassTest, FPClassTest>
258fcmpImpliesClass(CmpInst::Predicate Pred,constFunction &F,Value *LHS,
259constAPFloat &RHS,bool LookThroughSrc =true);
260
261structKnownFPClass {
262 /// Floating-point classes the value could be one of.
263FPClassTestKnownFPClasses =fcAllFlags;
264
265 /// std::nullopt if the sign bit is unknown, true if the sign bit is
266 /// definitely set or false if the sign bit is definitely unset.
267 std::optional<bool>SignBit;
268
269booloperator==(KnownFPClassOther) const{
270returnKnownFPClasses ==Other.KnownFPClasses &&SignBit ==Other.SignBit;
271 }
272
273 /// Return true if it's known this can never be one of the mask entries.
274boolisKnownNever(FPClassTest Mask) const{
275return (KnownFPClasses & Mask) ==fcNone;
276 }
277
278boolisKnownAlways(FPClassTest Mask) const{returnisKnownNever(~Mask); }
279
280boolisUnknown() const{
281returnKnownFPClasses ==fcAllFlags && !SignBit;
282 }
283
284 /// Return true if it's known this can never be a nan.
285boolisKnownNeverNaN() const{
286returnisKnownNever(fcNan);
287 }
288
289 /// Return true if it's known this must always be a nan.
290boolisKnownAlwaysNaN() const{returnisKnownAlways(fcNan); }
291
292 /// Return true if it's known this can never be an infinity.
293boolisKnownNeverInfinity() const{
294returnisKnownNever(fcInf);
295 }
296
297 /// Return true if it's known this can never be +infinity.
298boolisKnownNeverPosInfinity() const{
299returnisKnownNever(fcPosInf);
300 }
301
302 /// Return true if it's known this can never be -infinity.
303boolisKnownNeverNegInfinity() const{
304returnisKnownNever(fcNegInf);
305 }
306
307 /// Return true if it's known this can never be a subnormal
308boolisKnownNeverSubnormal() const{
309returnisKnownNever(fcSubnormal);
310 }
311
312 /// Return true if it's known this can never be a positive subnormal
313boolisKnownNeverPosSubnormal() const{
314returnisKnownNever(fcPosSubnormal);
315 }
316
317 /// Return true if it's known this can never be a negative subnormal
318boolisKnownNeverNegSubnormal() const{
319returnisKnownNever(fcNegSubnormal);
320 }
321
322 /// Return true if it's known this can never be a zero. This means a literal
323 /// [+-]0, and does not include denormal inputs implicitly treated as [+-]0.
324boolisKnownNeverZero() const{
325returnisKnownNever(fcZero);
326 }
327
328 /// Return true if it's known this can never be a literal positive zero.
329boolisKnownNeverPosZero() const{
330returnisKnownNever(fcPosZero);
331 }
332
333 /// Return true if it's known this can never be a negative zero. This means a
334 /// literal -0 and does not include denormal inputs implicitly treated as -0.
335boolisKnownNeverNegZero() const{
336returnisKnownNever(fcNegZero);
337 }
338
339 /// Return true if it's know this can never be interpreted as a zero. This
340 /// extends isKnownNeverZero to cover the case where the assumed
341 /// floating-point mode for the function interprets denormals as zero.
342boolisKnownNeverLogicalZero(constFunction &F,Type *Ty)const;
343
344 /// Return true if it's know this can never be interpreted as a negative zero.
345boolisKnownNeverLogicalNegZero(constFunction &F,Type *Ty)const;
346
347 /// Return true if it's know this can never be interpreted as a positive zero.
348boolisKnownNeverLogicalPosZero(constFunction &F,Type *Ty)const;
349
350staticconstexprFPClassTestOrderedLessThanZeroMask =
351fcNegSubnormal |fcNegNormal |fcNegInf;
352staticconstexprFPClassTestOrderedGreaterThanZeroMask =
353fcPosSubnormal |fcPosNormal |fcPosInf;
354
355 /// Return true if we can prove that the analyzed floating-point value is
356 /// either NaN or never less than -0.0.
357 ///
358 /// NaN --> true
359 /// +0 --> true
360 /// -0 --> true
361 /// x > +0 --> true
362 /// x < -0 --> false
363boolcannotBeOrderedLessThanZero() const{
364returnisKnownNever(OrderedLessThanZeroMask);
365 }
366
367 /// Return true if we can prove that the analyzed floating-point value is
368 /// either NaN or never greater than -0.0.
369 /// NaN --> true
370 /// +0 --> true
371 /// -0 --> true
372 /// x > +0 --> false
373 /// x < -0 --> true
374boolcannotBeOrderedGreaterThanZero() const{
375returnisKnownNever(OrderedGreaterThanZeroMask);
376 }
377
378KnownFPClass &operator|=(constKnownFPClass &RHS) {
379KnownFPClasses =KnownFPClasses |RHS.KnownFPClasses;
380
381if (SignBit !=RHS.SignBit)
382SignBit = std::nullopt;
383return *this;
384 }
385
386voidknownNot(FPClassTest RuleOut) {
387KnownFPClasses =KnownFPClasses & ~RuleOut;
388if (isKnownNever(fcNan) && !SignBit) {
389if (isKnownNever(fcNegative))
390SignBit =false;
391elseif (isKnownNever(fcPositive))
392SignBit =true;
393 }
394 }
395
396voidfneg() {
397KnownFPClasses =llvm::fneg(KnownFPClasses);
398if (SignBit)
399SignBit = !*SignBit;
400 }
401
402voidfabs() {
403if (KnownFPClasses &fcNegZero)
404KnownFPClasses |=fcPosZero;
405
406if (KnownFPClasses &fcNegInf)
407KnownFPClasses |=fcPosInf;
408
409if (KnownFPClasses &fcNegSubnormal)
410KnownFPClasses |=fcPosSubnormal;
411
412if (KnownFPClasses &fcNegNormal)
413KnownFPClasses |=fcPosNormal;
414
415signBitMustBeZero();
416 }
417
418 /// Return true if the sign bit must be 0, ignoring the sign of nans.
419boolsignBitIsZeroOrNaN() const{
420returnisKnownNever(fcNegative);
421 }
422
423 /// Assume the sign bit is zero.
424voidsignBitMustBeZero() {
425KnownFPClasses &= (fcPositive |fcNan);
426SignBit =false;
427 }
428
429 /// Assume the sign bit is one.
430voidsignBitMustBeOne() {
431KnownFPClasses &= (fcNegative |fcNan);
432SignBit =true;
433 }
434
435voidcopysign(constKnownFPClass &Sign) {
436// Don't know anything about the sign of the source. Expand the possible set
437// to its opposite sign pair.
438if (KnownFPClasses &fcZero)
439KnownFPClasses |=fcZero;
440if (KnownFPClasses &fcSubnormal)
441KnownFPClasses |=fcSubnormal;
442if (KnownFPClasses &fcNormal)
443KnownFPClasses |=fcNormal;
444if (KnownFPClasses &fcInf)
445KnownFPClasses |=fcInf;
446
447// Sign bit is exactly preserved even for nans.
448SignBit = Sign.SignBit;
449
450// Clear sign bits based on the input sign mask.
451if (Sign.isKnownNever(fcPositive |fcNan) || (SignBit && *SignBit))
452KnownFPClasses &= (fcNegative |fcNan);
453if (Sign.isKnownNever(fcNegative |fcNan) || (SignBit && !*SignBit))
454KnownFPClasses &= (fcPositive |fcNan);
455 }
456
457// Propagate knowledge that a non-NaN source implies the result can also not
458// be a NaN. For unconstrained operations, signaling nans are not guaranteed
459// to be quieted but cannot be introduced.
460voidpropagateNaN(constKnownFPClass &Src,bool PreserveSign =false) {
461if (Src.isKnownNever(fcNan)) {
462knownNot(fcNan);
463if (PreserveSign)
464SignBit = Src.SignBit;
465 }elseif (Src.isKnownNever(fcSNan))
466knownNot(fcSNan);
467 }
468
469 /// Propagate knowledge from a source value that could be a denormal or
470 /// zero. We have to be conservative since output flushing is not guaranteed,
471 /// so known-never-zero may not hold.
472 ///
473 /// This assumes a copy-like operation and will replace any currently known
474 /// information.
475voidpropagateDenormal(constKnownFPClass &Src,constFunction &F,Type *Ty);
476
477 /// Report known classes if \p Src is evaluated through a potentially
478 /// canonicalizing operation. We can assume signaling nans will not be
479 /// introduced, but cannot assume a denormal will be flushed under FTZ/DAZ.
480 ///
481 /// This assumes a copy-like operation and will replace any currently known
482 /// information.
483voidpropagateCanonicalizingSrc(constKnownFPClass &Src,constFunction &F,
484Type *Ty);
485
486voidresetAll() { *this =KnownFPClass(); }
487};
488
489inlineKnownFPClassoperator|(KnownFPClassLHS,constKnownFPClass &RHS) {
490LHS |=RHS;
491returnLHS;
492}
493
494inlineKnownFPClassoperator|(constKnownFPClass &LHS,KnownFPClass &&RHS) {
495RHS |=LHS;
496return std::move(RHS);
497}
498
499/// Determine which floating-point classes are valid for \p V, and return them
500/// in KnownFPClass bit sets.
501///
502/// This function is defined on values with floating-point type, values vectors
503/// of floating-point type, and arrays of floating-point type.
504
505/// \p InterestedClasses is a compile time optimization hint for which floating
506/// point classes should be queried. Queries not specified in \p
507/// InterestedClasses should be reliable if they are determined during the
508/// query.
509KnownFPClasscomputeKnownFPClass(const Value *V,const APInt &DemandedElts,
510FPClassTest InterestedClasses,unsignedDepth,
511const SimplifyQuery &SQ);
512
513KnownFPClasscomputeKnownFPClass(const Value *V,FPClassTest InterestedClasses,
514unsignedDepth,const SimplifyQuery &SQ);
515
516inlineKnownFPClasscomputeKnownFPClass(
517constValue *V,constDataLayout &DL,
518FPClassTest InterestedClasses =fcAllFlags,unsignedDepth = 0,
519constTargetLibraryInfo *TLI =nullptr,AssumptionCache *AC =nullptr,
520constInstruction *CxtI =nullptr,constDominatorTree *DT =nullptr,
521bool UseInstrInfo =true) {
522returncomputeKnownFPClass(
523 V, InterestedClasses,Depth,
524SimplifyQuery(DL, TLI, DT, AC, CxtI, UseInstrInfo));
525}
526
527/// Wrapper to account for known fast math flags at the use instruction.
528inline KnownFPClass
529computeKnownFPClass(constValue *V,constAPInt &DemandedElts,
530FastMathFlags FMF,FPClassTest InterestedClasses,
531unsignedDepth,constSimplifyQuery &SQ) {
532if (FMF.noNaNs())
533 InterestedClasses &= ~fcNan;
534if (FMF.noInfs())
535 InterestedClasses &= ~fcInf;
536
537KnownFPClass Result =
538computeKnownFPClass(V, DemandedElts, InterestedClasses,Depth, SQ);
539
540if (FMF.noNaNs())
541 Result.KnownFPClasses &= ~fcNan;
542if (FMF.noInfs())
543 Result.KnownFPClasses &= ~fcInf;
544return Result;
545}
546
547inlineKnownFPClasscomputeKnownFPClass(constValue *V,FastMathFlags FMF,
548FPClassTest InterestedClasses,
549unsignedDepth,
550constSimplifyQuery &SQ) {
551auto *FVTy = dyn_cast<FixedVectorType>(V->getType());
552APInt DemandedElts =
553 FVTy ?APInt::getAllOnes(FVTy->getNumElements()) :APInt(1, 1);
554returncomputeKnownFPClass(V, DemandedElts, FMF, InterestedClasses,Depth,
555 SQ);
556}
557
558/// Return true if we can prove that the specified FP value is never equal to
559/// -0.0. Users should use caution when considering PreserveSign
560/// denormal-fp-math.
561inlineboolcannotBeNegativeZero(constValue *V,unsignedDepth,
562constSimplifyQuery &SQ) {
563KnownFPClass Known =computeKnownFPClass(V,fcNegZero,Depth, SQ);
564return Known.isKnownNeverNegZero();
565}
566
567/// Return true if we can prove that the specified FP value is either NaN or
568/// never less than -0.0.
569///
570/// NaN --> true
571/// +0 --> true
572/// -0 --> true
573/// x > +0 --> true
574/// x < -0 --> false
575inlineboolcannotBeOrderedLessThanZero(constValue *V,unsignedDepth,
576constSimplifyQuery &SQ) {
577KnownFPClass Known =
578computeKnownFPClass(V,KnownFPClass::OrderedLessThanZeroMask,Depth, SQ);
579return Known.cannotBeOrderedLessThanZero();
580}
581
582/// Return true if the floating-point scalar value is not an infinity or if
583/// the floating-point vector value has no infinities. Return false if a value
584/// could ever be infinity.
585inlineboolisKnownNeverInfinity(constValue *V,unsignedDepth,
586constSimplifyQuery &SQ) {
587KnownFPClass Known =computeKnownFPClass(V,fcInf,Depth, SQ);
588return Known.isKnownNeverInfinity();
589}
590
591/// Return true if the floating-point value can never contain a NaN or infinity.
592inlineboolisKnownNeverInfOrNaN(constValue *V,unsignedDepth,
593constSimplifyQuery &SQ) {
594KnownFPClass Known =computeKnownFPClass(V,fcInf |fcNan,Depth, SQ);
595return Known.isKnownNeverNaN() && Known.isKnownNeverInfinity();
596}
597
598/// Return true if the floating-point scalar value is not a NaN or if the
599/// floating-point vector value has no NaN elements. Return false if a value
600/// could ever be NaN.
601inlineboolisKnownNeverNaN(constValue *V,unsignedDepth,
602constSimplifyQuery &SQ) {
603KnownFPClass Known =computeKnownFPClass(V,fcNan,Depth, SQ);
604return Known.isKnownNeverNaN();
605}
606
607/// Return false if we can prove that the specified FP value's sign bit is 0.
608/// Return true if we can prove that the specified FP value's sign bit is 1.
609/// Otherwise return std::nullopt.
610inline std::optional<bool>computeKnownFPSignBit(constValue *V,unsignedDepth,
611constSimplifyQuery &SQ) {
612KnownFPClass Known =computeKnownFPClass(V,fcAllFlags,Depth, SQ);
613return Known.SignBit;
614}
615
616/// If the specified value can be set by repeating the same byte in memory,
617/// return the i8 value that it is represented with. This is true for all i8
618/// values obviously, but is also true for i32 0, i32 -1, i16 0xF0F0, double
619/// 0.0 etc. If the value can't be handled with a repeated byte store (e.g.
620/// i16 0x1234), return null. If the value is entirely undef and padding,
621/// return undef.
622Value *isBytewiseValue(Value *V,const DataLayout &DL);
623
624/// Given an aggregate and an sequence of indices, see if the scalar value
625/// indexed is already around as a register, for example if it were inserted
626/// directly into the aggregate.
627///
628/// If InsertBefore is not empty, this function will duplicate (modified)
629/// insertvalues when a part of a nested struct is extracted.
630Value *FindInsertedValue(
631 Value *V, ArrayRef<unsigned> idx_range,
632 std::optional<BasicBlock::iterator> InsertBefore = std::nullopt);
633
634/// Analyze the specified pointer to see if it can be expressed as a base
635/// pointer plus a constant offset. Return the base and offset to the caller.
636///
637/// This is a wrapper around Value::stripAndAccumulateConstantOffsets that
638/// creates and later unpacks the required APInt.
639inlineValue *GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset,
640constDataLayout &DL,
641bool AllowNonInbounds =true) {
642APInt OffsetAPInt(DL.getIndexTypeSizeInBits(Ptr->getType()), 0);
643Value *Base =
644Ptr->stripAndAccumulateConstantOffsets(DL, OffsetAPInt, AllowNonInbounds);
645
646Offset = OffsetAPInt.getSExtValue();
647returnBase;
648}
649inlineconst Value *
650GetPointerBaseWithConstantOffset(constValue *Ptr, int64_t &Offset,
651constDataLayout &DL,
652bool AllowNonInbounds =true) {
653returnGetPointerBaseWithConstantOffset(const_cast<Value *>(Ptr),Offset,DL,
654 AllowNonInbounds);
655}
656
657/// Returns true if the GEP is based on a pointer to a string (array of
658// \p CharSize integers) and is indexing into this string.
659boolisGEPBasedOnPointerToString(const GEPOperator *GEP,unsigned CharSize = 8);
660
661/// Represents offset+length into a ConstantDataArray.
662structConstantDataArraySlice {
663 /// ConstantDataArray pointer. nullptr indicates a zeroinitializer (a valid
664 /// initializer, it just doesn't fit the ConstantDataArray interface).
665constConstantDataArray *Array;
666
667 /// Slice starts at this Offset.
668uint64_tOffset;
669
670 /// Length of the slice.
671uint64_tLength;
672
673 /// Moves the Offset and adjusts Length accordingly.
674voidmove(uint64_t Delta) {
675assert(Delta <Length);
676Offset += Delta;
677Length -= Delta;
678 }
679
680 /// Convenience accessor for elements in the slice.
681uint64_toperator[](unsignedI) const{
682returnArray ==nullptr ? 0 :Array->getElementAsInteger(I +Offset);
683 }
684};
685
686/// Returns true if the value \p V is a pointer into a ConstantDataArray.
687/// If successful \p Slice will point to a ConstantDataArray info object
688/// with an appropriate offset.
689boolgetConstantDataArrayInfo(const Value *V, ConstantDataArraySlice &Slice,
690unsigned ElementSize,uint64_tOffset = 0);
691
692/// This function computes the length of a null-terminated C string pointed to
693/// by V. If successful, it returns true and returns the string in Str. If
694/// unsuccessful, it returns false. This does not include the trailing null
695/// character by default. If TrimAtNul is set to false, then this returns any
696/// trailing null characters as well as any other characters that come after
697/// it.
698boolgetConstantStringInfo(const Value *V, StringRef &Str,
699bool TrimAtNul =true);
700
701/// If we can compute the length of the string pointed to by the specified
702/// pointer, return 'len+1'. If we can't, return 0.
703uint64_tGetStringLength(const Value *V,unsigned CharSize = 8);
704
705/// This function returns call pointer argument that is considered the same by
706/// aliasing rules. You CAN'T use it to replace one value with another. If
707/// \p MustPreserveNullness is true, the call must preserve the nullness of
708/// the pointer.
709const Value *getArgumentAliasingToReturnedPointer(const CallBase *Call,
710bool MustPreserveNullness);
711inlineValue *getArgumentAliasingToReturnedPointer(CallBase *Call,
712bool MustPreserveNullness) {
713returnconst_cast<Value *>(getArgumentAliasingToReturnedPointer(
714const_cast<constCallBase *>(Call), MustPreserveNullness));
715}
716
717/// {launder,strip}.invariant.group returns pointer that aliases its argument,
718/// and it only captures pointer by returning it.
719/// These intrinsics are not marked as nocapture, because returning is
720/// considered as capture. The arguments are not marked as returned neither,
721/// because it would make it useless. If \p MustPreserveNullness is true,
722/// the intrinsic must preserve the nullness of the pointer.
723boolisIntrinsicReturningPointerAliasingArgumentWithoutCapturing(
724const CallBase *Call,bool MustPreserveNullness);
725
726/// This method strips off any GEP address adjustments, pointer casts
727/// or `llvm.threadlocal.address` from the specified value \p V, returning the
728/// original object being addressed. Note that the returned value has pointer
729/// type if the specified value does. If the \p MaxLookup value is non-zero, it
730/// limits the number of instructions to be stripped off.
731const Value *getUnderlyingObject(const Value *V,unsigned MaxLookup = 6);
732inlineValue *getUnderlyingObject(Value *V,unsigned MaxLookup = 6) {
733// Force const to avoid infinite recursion.
734constValue *VConst = V;
735returnconst_cast<Value *>(getUnderlyingObject(VConst, MaxLookup));
736}
737
738/// Like getUnderlyingObject(), but will try harder to find a single underlying
739/// object. In particular, this function also looks through selects and phis.
740const Value *getUnderlyingObjectAggressive(const Value *V);
741
742/// This method is similar to getUnderlyingObject except that it can
743/// look through phi and select instructions and return multiple objects.
744///
745/// If LoopInfo is passed, loop phis are further analyzed. If a pointer
746/// accesses different objects in each iteration, we don't look through the
747/// phi node. E.g. consider this loop nest:
748///
749/// int **A;
750/// for (i)
751/// for (j) {
752/// A[i][j] = A[i-1][j] * B[j]
753/// }
754///
755/// This is transformed by Load-PRE to stash away A[i] for the next iteration
756/// of the outer loop:
757///
758/// Curr = A[0]; // Prev_0
759/// for (i: 1..N) {
760/// Prev = Curr; // Prev = PHI (Prev_0, Curr)
761/// Curr = A[i];
762/// for (j: 0..N) {
763/// Curr[j] = Prev[j] * B[j]
764/// }
765/// }
766///
767/// Since A[i] and A[i-1] are independent pointers, getUnderlyingObjects
768/// should not assume that Curr and Prev share the same underlying object thus
769/// it shouldn't look through the phi above.
770voidgetUnderlyingObjects(const Value *V,
771 SmallVectorImpl<const Value *> &Objects,
772const LoopInfo *LI =nullptr,unsigned MaxLookup = 6);
773
774/// This is a wrapper around getUnderlyingObjects and adds support for basic
775/// ptrtoint+arithmetic+inttoptr sequences.
776boolgetUnderlyingObjectsForCodeGen(const Value *V,
777 SmallVectorImpl<Value *> &Objects);
778
779/// Returns unique alloca where the value comes from, or nullptr.
780/// If OffsetZero is true check that V points to the begining of the alloca.
781AllocaInst *findAllocaForValue(Value *V,bool OffsetZero =false);
782inlineconstAllocaInst *findAllocaForValue(constValue *V,
783bool OffsetZero =false) {
784returnfindAllocaForValue(const_cast<Value *>(V), OffsetZero);
785}
786
787/// Return true if the only users of this pointer are lifetime markers.
788boolonlyUsedByLifetimeMarkers(const Value *V);
789
790/// Return true if the only users of this pointer are lifetime markers or
791/// droppable instructions.
792boolonlyUsedByLifetimeMarkersOrDroppableInsts(const Value *V);
793
794/// Return true if the instruction doesn't potentially cross vector lanes. This
795/// condition is weaker than checking that the instruction is lanewise: lanewise
796/// means that the same operation is splatted across all lanes, but we also
797/// include the case where there is a different operation on each lane, as long
798/// as the operation only uses data from that lane. An example of an operation
799/// that is not lanewise, but doesn't cross vector lanes is insertelement.
800boolisNotCrossLaneOperation(const Instruction *I);
801
802/// Return true if the instruction does not have any effects besides
803/// calculating the result and does not have undefined behavior.
804///
805/// This method never returns true for an instruction that returns true for
806/// mayHaveSideEffects; however, this method also does some other checks in
807/// addition. It checks for undefined behavior, like dividing by zero or
808/// loading from an invalid pointer (but not for undefined results, like a
809/// shift with a shift amount larger than the width of the result). It checks
810/// for malloc and alloca because speculatively executing them might cause a
811/// memory leak. It also returns false for instructions related to control
812/// flow, specifically terminators and PHI nodes.
813///
814/// If the CtxI is specified this method performs context-sensitive analysis
815/// and returns true if it is safe to execute the instruction immediately
816/// before the CtxI. If the instruction has (transitive) operands that don't
817/// dominate CtxI, the analysis is performed under the assumption that these
818/// operands will also be speculated to a point before CxtI.
819///
820/// If the CtxI is NOT specified this method only looks at the instruction
821/// itself and its operands, so if this method returns true, it is safe to
822/// move the instruction as long as the correct dominance relationships for
823/// the operands and users hold.
824///
825/// This method can return true for instructions that read memory;
826/// for such instructions, moving them may change the resulting value.
827boolisSafeToSpeculativelyExecute(const Instruction *I,
828const Instruction *CtxI =nullptr,
829 AssumptionCache *AC =nullptr,
830const DominatorTree *DT =nullptr,
831const TargetLibraryInfo *TLI =nullptr,
832bool UseVariableInfo =true);
833
834inlineboolisSafeToSpeculativelyExecute(constInstruction *I,
835BasicBlock::iterator CtxI,
836AssumptionCache *AC =nullptr,
837constDominatorTree *DT =nullptr,
838constTargetLibraryInfo *TLI =nullptr,
839bool UseVariableInfo =true) {
840// Take an iterator, and unwrap it into an Instruction *.
841returnisSafeToSpeculativelyExecute(I, &*CtxI, AC, DT, TLI, UseVariableInfo);
842}
843
844/// Don't use information from its non-constant operands. This helper is used
845/// when its operands are going to be replaced.
846inlinebool
847isSafeToSpeculativelyExecuteWithVariableReplaced(constInstruction *I) {
848returnisSafeToSpeculativelyExecute(I,nullptr,nullptr,nullptr,nullptr,
849/*UseVariableInfo=*/false);
850}
851
852/// This returns the same result as isSafeToSpeculativelyExecute if Opcode is
853/// the actual opcode of Inst. If the provided and actual opcode differ, the
854/// function (virtually) overrides the opcode of Inst with the provided
855/// Opcode. There are come constraints in this case:
856/// * If Opcode has a fixed number of operands (eg, as binary operators do),
857/// then Inst has to have at least as many leading operands. The function
858/// will ignore all trailing operands beyond that number.
859/// * If Opcode allows for an arbitrary number of operands (eg, as CallInsts
860/// do), then all operands are considered.
861/// * The virtual instruction has to satisfy all typing rules of the provided
862/// Opcode.
863/// * This function is pessimistic in the following sense: If one actually
864/// materialized the virtual instruction, then isSafeToSpeculativelyExecute
865/// may say that the materialized instruction is speculatable whereas this
866/// function may have said that the instruction wouldn't be speculatable.
867/// This behavior is a shortcoming in the current implementation and not
868/// intentional.
869boolisSafeToSpeculativelyExecuteWithOpcode(
870unsigned Opcode,const Instruction *Inst,const Instruction *CtxI =nullptr,
871 AssumptionCache *AC =nullptr,const DominatorTree *DT =nullptr,
872const TargetLibraryInfo *TLI =nullptr,bool UseVariableInfo =true);
873
874/// Returns true if the result or effects of the given instructions \p I
875/// depend values not reachable through the def use graph.
876/// * Memory dependence arises for example if the instruction reads from
877/// memory or may produce effects or undefined behaviour. Memory dependent
878/// instructions generally cannot be reorderd with respect to other memory
879/// dependent instructions.
880/// * Control dependence arises for example if the instruction may fault
881/// if lifted above a throwing call or infinite loop.
882boolmayHaveNonDefUseDependency(const Instruction &I);
883
884/// Return true if it is an intrinsic that cannot be speculated but also
885/// cannot trap.
886boolisAssumeLikeIntrinsic(const Instruction *I);
887
888/// Return true if it is valid to use the assumptions provided by an
889/// assume intrinsic, I, at the point in the control-flow identified by the
890/// context instruction, CxtI. By default, ephemeral values of the assumption
891/// are treated as an invalid context, to prevent the assumption from being used
892/// to optimize away its argument. If the caller can ensure that this won't
893/// happen, it can call with AllowEphemerals set to true to get more valid
894/// assumptions.
895boolisValidAssumeForContext(const Instruction *I,const Instruction *CxtI,
896const DominatorTree *DT =nullptr,
897bool AllowEphemerals =false);
898
899enum classOverflowResult {
900 /// Always overflows in the direction of signed/unsigned min value.
901AlwaysOverflowsLow,
902 /// Always overflows in the direction of signed/unsigned max value.
903AlwaysOverflowsHigh,
904 /// May or may not overflow.
905MayOverflow,
906 /// Never overflows.
907NeverOverflows,
908};
909
910OverflowResultcomputeOverflowForUnsignedMul(const Value *LHS,const Value *RHS,
911const SimplifyQuery &SQ,
912bool IsNSW =false);
913OverflowResultcomputeOverflowForSignedMul(const Value *LHS,const Value *RHS,
914const SimplifyQuery &SQ);
915OverflowResult
916computeOverflowForUnsignedAdd(const WithCache<const Value *> &LHS,
917const WithCache<const Value *> &RHS,
918const SimplifyQuery &SQ);
919OverflowResultcomputeOverflowForSignedAdd(const WithCache<const Value *> &LHS,
920const WithCache<const Value *> &RHS,
921const SimplifyQuery &SQ);
922/// This version also leverages the sign bit of Add if known.
923OverflowResultcomputeOverflowForSignedAdd(const AddOperator *Add,
924const SimplifyQuery &SQ);
925OverflowResultcomputeOverflowForUnsignedSub(const Value *LHS,const Value *RHS,
926const SimplifyQuery &SQ);
927OverflowResultcomputeOverflowForSignedSub(const Value *LHS,const Value *RHS,
928const SimplifyQuery &SQ);
929
930/// Returns true if the arithmetic part of the \p WO 's result is
931/// used only along the paths control dependent on the computation
932/// not overflowing, \p WO being an <op>.with.overflow intrinsic.
933boolisOverflowIntrinsicNoWrap(const WithOverflowInst *WO,
934const DominatorTree &DT);
935
936/// Determine the possible constant range of vscale with the given bit width,
937/// based on the vscale_range function attribute.
938ConstantRangegetVScaleRange(const Function *F,unsignedBitWidth);
939
940/// Determine the possible constant range of an integer or vector of integer
941/// value. This is intended as a cheap, non-recursive check.
942ConstantRangecomputeConstantRange(const Value *V,bool ForSigned,
943bool UseInstrInfo =true,
944 AssumptionCache *AC =nullptr,
945const Instruction *CtxI =nullptr,
946const DominatorTree *DT =nullptr,
947unsignedDepth = 0);
948
949/// Combine constant ranges from computeConstantRange() and computeKnownBits().
950ConstantRange
951computeConstantRangeIncludingKnownBits(const WithCache<const Value *> &V,
952bool ForSigned,const SimplifyQuery &SQ);
953
954/// Return true if this function can prove that the instruction I will
955/// always transfer execution to one of its successors (including the next
956/// instruction that follows within a basic block). E.g. this is not
957/// guaranteed for function calls that could loop infinitely.
958///
959/// In other words, this function returns false for instructions that may
960/// transfer execution or fail to transfer execution in a way that is not
961/// captured in the CFG nor in the sequence of instructions within a basic
962/// block.
963///
964/// Undefined behavior is assumed not to happen, so e.g. division is
965/// guaranteed to transfer execution to the following instruction even
966/// though division by zero might cause undefined behavior.
967boolisGuaranteedToTransferExecutionToSuccessor(const Instruction *I);
968
969/// Returns true if this block does not contain a potential implicit exit.
970/// This is equivelent to saying that all instructions within the basic block
971/// are guaranteed to transfer execution to their successor within the basic
972/// block. This has the same assumptions w.r.t. undefined behavior as the
973/// instruction variant of this function.
974boolisGuaranteedToTransferExecutionToSuccessor(const BasicBlock *BB);
975
976/// Return true if every instruction in the range (Begin, End) is
977/// guaranteed to transfer execution to its static successor. \p ScanLimit
978/// bounds the search to avoid scanning huge blocks.
979boolisGuaranteedToTransferExecutionToSuccessor(
980BasicBlock::const_iterator Begin,BasicBlock::const_iteratorEnd,
981unsigned ScanLimit = 32);
982
983/// Same as previous, but with range expressed via iterator_range.
984boolisGuaranteedToTransferExecutionToSuccessor(
985 iterator_range<BasicBlock::const_iterator>Range,unsigned ScanLimit = 32);
986
987/// Return true if this function can prove that the instruction I
988/// is executed for every iteration of the loop L.
989///
990/// Note that this currently only considers the loop header.
991boolisGuaranteedToExecuteForEveryIteration(const Instruction *I,
992const Loop *L);
993
994/// Return true if \p PoisonOp's user yields poison or raises UB if its
995/// operand \p PoisonOp is poison.
996///
997/// If \p PoisonOp is a vector or an aggregate and the operation's result is a
998/// single value, any poison element in /p PoisonOp should make the result
999/// poison or raise UB.
1000///
1001/// To filter out operands that raise UB on poison, you can use
1002/// getGuaranteedNonPoisonOp.
1003boolpropagatesPoison(const Use &PoisonOp);
1004
1005/// Insert operands of I into Ops such that I will trigger undefined behavior
1006/// if I is executed and that operand has a poison value.
1007voidgetGuaranteedNonPoisonOps(const Instruction *I,
1008 SmallVectorImpl<const Value *> &Ops);
1009
1010/// Insert operands of I into Ops such that I will trigger undefined behavior
1011/// if I is executed and that operand is not a well-defined value
1012/// (i.e. has undef bits or poison).
1013voidgetGuaranteedWellDefinedOps(const Instruction *I,
1014 SmallVectorImpl<const Value *> &Ops);
1015
1016/// Return true if the given instruction must trigger undefined behavior
1017/// when I is executed with any operands which appear in KnownPoison holding
1018/// a poison value at the point of execution.
1019boolmustTriggerUB(const Instruction *I,
1020const SmallPtrSetImpl<const Value *> &KnownPoison);
1021
1022/// Return true if this function can prove that if Inst is executed
1023/// and yields a poison value or undef bits, then that will trigger
1024/// undefined behavior.
1025///
1026/// Note that this currently only considers the basic block that is
1027/// the parent of Inst.
1028boolprogramUndefinedIfUndefOrPoison(const Instruction *Inst);
1029boolprogramUndefinedIfPoison(const Instruction *Inst);
1030
1031/// canCreateUndefOrPoison returns true if Op can create undef or poison from
1032/// non-undef & non-poison operands.
1033/// For vectors, canCreateUndefOrPoison returns true if there is potential
1034/// poison or undef in any element of the result when vectors without
1035/// undef/poison poison are given as operands.
1036/// For example, given `Op = shl <2 x i32> %x, <0, 32>`, this function returns
1037/// true. If Op raises immediate UB but never creates poison or undef
1038/// (e.g. sdiv I, 0), canCreatePoison returns false.
1039///
1040/// \p ConsiderFlagsAndMetadata controls whether poison producing flags and
1041/// metadata on the instruction are considered. This can be used to see if the
1042/// instruction could still introduce undef or poison even without poison
1043/// generating flags and metadata which might be on the instruction.
1044/// (i.e. could the result of Op->dropPoisonGeneratingFlags() still create
1045/// poison or undef)
1046///
1047/// canCreatePoison returns true if Op can create poison from non-poison
1048/// operands.
1049boolcanCreateUndefOrPoison(const Operator *Op,
1050bool ConsiderFlagsAndMetadata =true);
1051boolcanCreatePoison(const Operator *Op,bool ConsiderFlagsAndMetadata =true);
1052
1053/// Return true if V is poison given that ValAssumedPoison is already poison.
1054/// For example, if ValAssumedPoison is `icmp X, 10` and V is `icmp X, 5`,
1055/// impliesPoison returns true.
1056boolimpliesPoison(const Value *ValAssumedPoison,const Value *V);
1057
1058/// Return true if this function can prove that V does not have undef bits
1059/// and is never poison. If V is an aggregate value or vector, check whether
1060/// all elements (except padding) are not undef or poison.
1061/// Note that this is different from canCreateUndefOrPoison because the
1062/// function assumes Op's operands are not poison/undef.
1063///
1064/// If CtxI and DT are specified this method performs flow-sensitive analysis
1065/// and returns true if it is guaranteed to be never undef or poison
1066/// immediately before the CtxI.
1067boolisGuaranteedNotToBeUndefOrPoison(const Value *V,
1068 AssumptionCache *AC =nullptr,
1069const Instruction *CtxI =nullptr,
1070const DominatorTree *DT =nullptr,
1071unsignedDepth = 0);
1072
1073/// Returns true if V cannot be poison, but may be undef.
1074boolisGuaranteedNotToBePoison(const Value *V, AssumptionCache *AC =nullptr,
1075const Instruction *CtxI =nullptr,
1076const DominatorTree *DT =nullptr,
1077unsignedDepth = 0);
1078
1079inlineboolisGuaranteedNotToBePoison(constValue *V,AssumptionCache *AC,
1080BasicBlock::iterator CtxI,
1081constDominatorTree *DT =nullptr,
1082unsignedDepth = 0) {
1083// Takes an iterator as a position, passes down to Instruction *
1084// implementation.
1085returnisGuaranteedNotToBePoison(V, AC, &*CtxI, DT,Depth);
1086}
1087
1088/// Returns true if V cannot be undef, but may be poison.
1089boolisGuaranteedNotToBeUndef(const Value *V, AssumptionCache *AC =nullptr,
1090const Instruction *CtxI =nullptr,
1091const DominatorTree *DT =nullptr,
1092unsignedDepth = 0);
1093
1094/// Return true if undefined behavior would provable be executed on the path to
1095/// OnPathTo if Root produced a posion result. Note that this doesn't say
1096/// anything about whether OnPathTo is actually executed or whether Root is
1097/// actually poison. This can be used to assess whether a new use of Root can
1098/// be added at a location which is control equivalent with OnPathTo (such as
1099/// immediately before it) without introducing UB which didn't previously
1100/// exist. Note that a false result conveys no information.
1101boolmustExecuteUBIfPoisonOnPathTo(Instruction *Root,
1102 Instruction *OnPathTo,
1103 DominatorTree *DT);
1104
1105/// Convert an integer comparison with a constant RHS into an equivalent
1106/// form with the strictness flipped predicate. Return the new predicate and
1107/// corresponding constant RHS if possible. Otherwise return std::nullopt.
1108/// E.g., (icmp sgt X, 0) -> (icmp sle X, 1).
1109std::optional<std::pair<CmpPredicate, Constant *>>
1110getFlippedStrictnessPredicateAndConstant(CmpPredicate Pred, Constant *C);
1111
1112/// Specific patterns of select instructions we can match.
1113enumSelectPatternFlavor {
1114SPF_UNKNOWN = 0,
1115SPF_SMIN,/// Signed minimum
1116SPF_UMIN,/// Unsigned minimum
1117SPF_SMAX,/// Signed maximum
1118SPF_UMAX,/// Unsigned maximum
1119SPF_FMINNUM,/// Floating point minnum
1120SPF_FMAXNUM,/// Floating point maxnum
1121SPF_ABS,/// Absolute value
1122SPF_NABS/// Negated absolute value
1123};
1124
1125/// Behavior when a floating point min/max is given one NaN and one
1126/// non-NaN as input.
1127enumSelectPatternNaNBehavior {
1128SPNB_NA = 0,/// NaN behavior not applicable.
1129SPNB_RETURNS_NAN,/// Given one NaN input, returns the NaN.
1130SPNB_RETURNS_OTHER,/// Given one NaN input, returns the non-NaN.
1131SPNB_RETURNS_ANY/// Given one NaN input, can return either (or
1132 /// it has been determined that no operands can
1133 /// be NaN).
1134};
1135
1136structSelectPatternResult {
1137SelectPatternFlavorFlavor;
1138SelectPatternNaNBehaviorNaNBehavior;/// Only applicable if Flavor is
1139 /// SPF_FMINNUM or SPF_FMAXNUM.
1140boolOrdered;/// When implementing this min/max pattern as
1141 /// fcmp; select, does the fcmp have to be
1142 /// ordered?
1143
1144 /// Return true if \p SPF is a min or a max pattern.
1145staticboolisMinOrMax(SelectPatternFlavor SPF) {
1146return SPF !=SPF_UNKNOWN && SPF !=SPF_ABS && SPF !=SPF_NABS;
1147 }
1148};
1149
1150/// Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind
1151/// and providing the out parameter results if we successfully match.
1152///
1153/// For ABS/NABS, LHS will be set to the input to the abs idiom. RHS will be
1154/// the negation instruction from the idiom.
1155///
1156/// If CastOp is not nullptr, also match MIN/MAX idioms where the type does
1157/// not match that of the original select. If this is the case, the cast
1158/// operation (one of Trunc,SExt,Zext) that must be done to transform the
1159/// type of LHS and RHS into the type of V is returned in CastOp.
1160///
1161/// For example:
1162/// %1 = icmp slt i32 %a, i32 4
1163/// %2 = sext i32 %a to i64
1164/// %3 = select i1 %1, i64 %2, i64 4
1165///
1166/// -> LHS = %a, RHS = i32 4, *CastOp = Instruction::SExt
1167///
1168SelectPatternResultmatchSelectPattern(Value *V, Value *&LHS, Value *&RHS,
1169Instruction::CastOps *CastOp =nullptr,
1170unsignedDepth = 0);
1171
1172inlineSelectPatternResultmatchSelectPattern(constValue *V,constValue *&LHS,
1173constValue *&RHS) {
1174Value *L =const_cast<Value *>(LHS);
1175Value *R =const_cast<Value *>(RHS);
1176auto Result =matchSelectPattern(const_cast<Value *>(V), L, R);
1177LHS = L;
1178RHS = R;
1179return Result;
1180}
1181
1182/// Determine the pattern that a select with the given compare as its
1183/// predicate and given values as its true/false operands would match.
1184SelectPatternResultmatchDecomposedSelectPattern(
1185 CmpInst *CmpI, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS,
1186Instruction::CastOps *CastOp =nullptr,unsignedDepth = 0);
1187
1188/// Determine the pattern for predicate `X Pred Y ? X : Y`.
1189SelectPatternResult
1190getSelectPattern(CmpInst::Predicate Pred,
1191SelectPatternNaNBehavior NaNBehavior =SPNB_NA,
1192bool Ordered =false);
1193
1194/// Return the canonical comparison predicate for the specified
1195/// minimum/maximum flavor.
1196CmpInst::PredicategetMinMaxPred(SelectPatternFlavor SPF,bool Ordered =false);
1197
1198/// Convert given `SPF` to equivalent min/max intrinsic.
1199/// Caller must ensure `SPF` is an integer min or max pattern.
1200Intrinsic::IDgetMinMaxIntrinsic(SelectPatternFlavor SPF);
1201
1202/// Return the inverse minimum/maximum flavor of the specified flavor.
1203/// For example, signed minimum is the inverse of signed maximum.
1204SelectPatternFlavorgetInverseMinMaxFlavor(SelectPatternFlavor SPF);
1205
1206Intrinsic::IDgetInverseMinMaxIntrinsic(Intrinsic::ID MinMaxID);
1207
1208/// Return the minimum or maximum constant value for the specified integer
1209/// min/max flavor and type.
1210APIntgetMinMaxLimit(SelectPatternFlavor SPF,unsignedBitWidth);
1211
1212/// Check if the values in \p VL are select instructions that can be converted
1213/// to a min or max (vector) intrinsic. Returns the intrinsic ID, if such a
1214/// conversion is possible, together with a bool indicating whether all select
1215/// conditions are only used by the selects. Otherwise return
1216/// Intrinsic::not_intrinsic.
1217std::pair<Intrinsic::ID, bool>
1218canConvertToMinOrMaxIntrinsic(ArrayRef<Value *> VL);
1219
1220/// Attempt to match a simple first order recurrence cycle of the form:
1221/// %iv = phi Ty [%Start, %Entry], [%Inc, %backedge]
1222/// %inc = binop %iv, %step
1223/// OR
1224/// %iv = phi Ty [%Start, %Entry], [%Inc, %backedge]
1225/// %inc = binop %step, %iv
1226///
1227/// A first order recurrence is a formula with the form: X_n = f(X_(n-1))
1228///
1229/// A couple of notes on subtleties in that definition:
1230/// * The Step does not have to be loop invariant. In math terms, it can
1231/// be a free variable. We allow recurrences with both constant and
1232/// variable coefficients. Callers may wish to filter cases where Step
1233/// does not dominate P.
1234/// * For non-commutative operators, we will match both forms. This
1235/// results in some odd recurrence structures. Callers may wish to filter
1236/// out recurrences where the phi is not the LHS of the returned operator.
1237/// * Because of the structure matched, the caller can assume as a post
1238/// condition of the match the presence of a Loop with P's parent as it's
1239/// header *except* in unreachable code. (Dominance decays in unreachable
1240/// code.)
1241///
1242/// NOTE: This is intentional simple. If you want the ability to analyze
1243/// non-trivial loop conditons, see ScalarEvolution instead.
1244boolmatchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO, Value *&Start,
1245 Value *&Step);
1246
1247/// Analogous to the above, but starting from the binary operator
1248boolmatchSimpleRecurrence(const BinaryOperator *I, PHINode *&P, Value *&Start,
1249 Value *&Step);
1250
1251/// Return true if RHS is known to be implied true by LHS. Return false if
1252/// RHS is known to be implied false by LHS. Otherwise, return std::nullopt if
1253/// no implication can be made. A & B must be i1 (boolean) values or a vector of
1254/// such values. Note that the truth table for implication is the same as <=u on
1255/// i1 values (but not
1256/// <=s!). The truth table for both is:
1257/// | T | F (B)
1258/// T | T | F
1259/// F | T | T
1260/// (A)
1261std::optional<bool>isImpliedCondition(const Value *LHS,const Value *RHS,
1262const DataLayout &DL,
1263bool LHSIsTrue =true,
1264unsignedDepth = 0);
1265std::optional<bool>isImpliedCondition(const Value *LHS, CmpPredicate RHSPred,
1266const Value *RHSOp0,const Value *RHSOp1,
1267const DataLayout &DL,
1268bool LHSIsTrue =true,
1269unsignedDepth = 0);
1270
1271/// Return the boolean condition value in the context of the given instruction
1272/// if it is known based on dominating conditions.
1273std::optional<bool>isImpliedByDomCondition(const Value *Cond,
1274const Instruction *ContextI,
1275const DataLayout &DL);
1276std::optional<bool>isImpliedByDomCondition(CmpPredicate Pred,const Value *LHS,
1277const Value *RHS,
1278const Instruction *ContextI,
1279const DataLayout &DL);
1280
1281/// Call \p InsertAffected on all Values whose known bits / value may be
1282/// affected by the condition \p Cond. Used by AssumptionCache and
1283/// DomConditionCache.
1284voidfindValuesAffectedByCondition(Value *Cond,bool IsAssume,
1285 function_ref<void(Value *)> InsertAffected);
1286
1287}// end namespace llvm
1288
1289#endif// LLVM_ANALYSIS_VALUETRACKING_H
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DataLayout.h
End
bool End
Definition:ELF_riscv.cpp:480
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
FMF.h
GEP
Hexagon Common GEP
Definition:HexagonCommonGEP.cpp:170
InstrTypes.h
Instructions.h
Intrinsics.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
Range
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
P
#define P(N)
Cond
const SmallVectorImpl< MachineOperand > & Cond
Definition:RISCVRedundantCopyElimination.cpp:75
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SimplifyQuery.h
Ptr
@ Ptr
Definition:TargetLibraryInfo.cpp:77
WithCache.h
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
llvm::APFloat
Definition:APFloat.h:904
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::APInt::getAllOnes
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
Definition:APInt.h:234
llvm::APInt::getSExtValue
int64_t getSExtValue() const
Get sign extended value.
Definition:APInt.h:1542
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition:Instructions.h:63
llvm::AssumptionCache
A cache of @llvm.assume calls within a function.
Definition:AssumptionCache.h:42
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition:BasicBlock.h:178
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition:BasicBlock.h:177
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition:InstrTypes.h:1112
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition:InstrTypes.h:673
llvm::ConstantDataArray
An array constant whose element type is a simple 1/2/4/8-byte integer or float/double,...
Definition:Constants.h:696
llvm::ConstantDataSequential::getElementAsInteger
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
Definition:Constants.cpp:3115
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition:Dominators.h:162
llvm::FastMathFlags
Convenience struct for specifying and reasoning about fast-math flags.
Definition:FMF.h:20
llvm::FastMathFlags::noInfs
bool noInfs() const
Definition:FMF.h:67
llvm::FastMathFlags::noNaNs
bool noNaNs() const
Definition:FMF.h:66
llvm::Function
Definition:Function.h:63
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::CastOps
CastOps
Definition:Instruction.h:1003
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::Operator
This is a utility class that provides an abstraction for the common functionality between Instruction...
Definition:Operator.h:32
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition:TargetLibraryInfo.h:280
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::WithCache
Definition:WithCache.h:27
uint64_t
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::Intrinsic::ID
unsigned ID
Definition:GenericSSAContext.h:28
llvm::sampleprof::Base
@ Base
Definition:Discriminator.h:58
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::haveNoCommonBitsSet
bool haveNoCommonBitsSet(const WithCache< const Value * > &LHSCache, const WithCache< const Value * > &RHSCache, const SimplifyQuery &SQ)
Return true if LHS and RHS have no common bits set.
Definition:ValueTracking.cpp:248
llvm::mustExecuteUBIfPoisonOnPathTo
bool mustExecuteUBIfPoisonOnPathTo(Instruction *Root, Instruction *OnPathTo, DominatorTree *DT)
Return true if undefined behavior would provable be executed on the path to OnPathTo if Root produced...
Definition:ValueTracking.cpp:7870
llvm::getInverseMinMaxIntrinsic
Intrinsic::ID getInverseMinMaxIntrinsic(Intrinsic::ID MinMaxID)
Definition:ValueTracking.cpp:9140
llvm::Offset
@ Offset
Definition:DWP.cpp:480
llvm::OverflowResult
OverflowResult
Definition:ValueTracking.h:899
llvm::OverflowResult::NeverOverflows
@ NeverOverflows
Never overflows.
llvm::OverflowResult::AlwaysOverflowsHigh
@ AlwaysOverflowsHigh
Always overflows in the direction of signed/unsigned max value.
llvm::OverflowResult::AlwaysOverflowsLow
@ AlwaysOverflowsLow
Always overflows in the direction of signed/unsigned min value.
llvm::OverflowResult::MayOverflow
@ MayOverflow
May or may not overflow.
llvm::isValidAssumeForContext
bool isValidAssumeForContext(const Instruction *I, const Instruction *CxtI, const DominatorTree *DT=nullptr, bool AllowEphemerals=false)
Return true if it is valid to use the assumptions provided by an assume intrinsic,...
Definition:ValueTracking.cpp:509
llvm::canCreatePoison
bool canCreatePoison(const Operator *Op, bool ConsiderFlagsAndMetadata=true)
Definition:ValueTracking.cpp:7636
llvm::mustTriggerUB
bool mustTriggerUB(const Instruction *I, const SmallPtrSetImpl< const Value * > &KnownPoison)
Return true if the given instruction must trigger undefined behavior when I is executed with any oper...
Definition:ValueTracking.cpp:8151
llvm::isSafeToSpeculativelyExecuteWithVariableReplaced
bool isSafeToSpeculativelyExecuteWithVariableReplaced(const Instruction *I)
Don't use information from its non-constant operands.
Definition:ValueTracking.h:847
llvm::isOnlyUsedInZeroEqualityComparison
bool isOnlyUsedInZeroEqualityComparison(const Instruction *CxtI)
Definition:ValueTracking.cpp:273
llvm::isSignBitCheck
bool isSignBitCheck(ICmpInst::Predicate Pred, const APInt &RHS, bool &TrueIfSigned)
Given an exploded icmp instruction, return true if the comparison only checks the sign bit.
Definition:ValueTracking.cpp:4481
llvm::Depth
@ Depth
Definition:SIMachineScheduler.h:36
llvm::getArgumentAliasingToReturnedPointer
const Value * getArgumentAliasingToReturnedPointer(const CallBase *Call, bool MustPreserveNullness)
This function returns call pointer argument that is considered the same by aliasing rules.
Definition:ValueTracking.cpp:6699
llvm::isAssumeLikeIntrinsic
bool isAssumeLikeIntrinsic(const Instruction *I)
Return true if it is an intrinsic that cannot be speculated but also cannot trap.
Definition:ValueTracking.cpp:502
llvm::findAllocaForValue
AllocaInst * findAllocaForValue(Value *V, bool OffsetZero=false)
Returns unique alloca where the value comes from, or nullptr.
Definition:ValueTracking.cpp:6963
llvm::getMinMaxLimit
APInt getMinMaxLimit(SelectPatternFlavor SPF, unsigned BitWidth)
Return the minimum or maximum constant value for the specified integer min/max flavor and type.
Definition:ValueTracking.cpp:9156
llvm::isKnownNeverInfinity
bool isKnownNeverInfinity(const Value *V, unsigned Depth, const SimplifyQuery &SQ)
Return true if the floating-point scalar value is not an infinity or if the floating-point vector val...
Definition:ValueTracking.h:585
llvm::getGuaranteedNonPoisonOps
void getGuaranteedNonPoisonOps(const Instruction *I, SmallVectorImpl< const Value * > &Ops)
Insert operands of I into Ops such that I will trigger undefined behavior if I is executed and that o...
Definition:ValueTracking.cpp:8143
llvm::isOnlyUsedInZeroComparison
bool isOnlyUsedInZeroComparison(const Instruction *CxtI)
Definition:ValueTracking.cpp:267
llvm::getConstantStringInfo
bool getConstantStringInfo(const Value *V, StringRef &Str, bool TrimAtNul=true)
This function computes the length of a null-terminated C string pointed to by V.
Definition:ValueTracking.cpp:6576
llvm::onlyUsedByLifetimeMarkersOrDroppableInsts
bool onlyUsedByLifetimeMarkersOrDroppableInsts(const Value *V)
Return true if the only users of this pointer are lifetime markers or droppable instructions.
Definition:ValueTracking.cpp:7030
llvm::getUnderlyingObjectsForCodeGen
bool getUnderlyingObjectsForCodeGen(const Value *V, SmallVectorImpl< Value * > &Objects)
This is a wrapper around getUnderlyingObjects and adds support for basic ptrtoint+arithmetic+inttoptr...
Definition:ValueTracking.cpp:6930
llvm::canConvertToMinOrMaxIntrinsic
std::pair< Intrinsic::ID, bool > canConvertToMinOrMaxIntrinsic(ArrayRef< Value * > VL)
Check if the values in VL are select instructions that can be converted to a min or max (vector) intr...
Definition:ValueTracking.cpp:9167
llvm::getConstantDataArrayInfo
bool getConstantDataArrayInfo(const Value *V, ConstantDataArraySlice &Slice, unsigned ElementSize, uint64_t Offset=0)
Returns true if the value V is a pointer into a ConstantDataArray.
Definition:ValueTracking.cpp:6481
llvm::isGuaranteedToExecuteForEveryIteration
bool isGuaranteedToExecuteForEveryIteration(const Instruction *I, const Loop *L)
Return true if this function can prove that the instruction I is executed for every iteration of the ...
Definition:ValueTracking.cpp:7982
llvm::GetPointerBaseWithConstantOffset
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL, bool AllowNonInbounds=true)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset.
Definition:ValueTracking.h:639
llvm::getUnderlyingObject
const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=6)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
Definition:ValueTracking.cpp:6768
llvm::isKnownToBeAPowerOfTwo
bool isKnownToBeAPowerOfTwo(const Value *V, const DataLayout &DL, bool OrZero=false, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if the given value is known to have exactly one bit set when defined.
Definition:ValueTracking.cpp:280
llvm::isKnownNeverInfOrNaN
bool isKnownNeverInfOrNaN(const Value *V, unsigned Depth, const SimplifyQuery &SQ)
Return true if the floating-point value can never contain a NaN or infinity.
Definition:ValueTracking.h:592
llvm::getMinMaxPred
CmpInst::Predicate getMinMaxPred(SelectPatternFlavor SPF, bool Ordered=false)
Return the canonical comparison predicate for the specified minimum/maximum flavor.
Definition:ValueTracking.cpp:9105
llvm::computeKnownBitsFromContext
void computeKnownBitsFromContext(const Value *V, KnownBits &Known, unsigned Depth, const SimplifyQuery &Q)
Merge bits known from context-dependent facts into Known.
Definition:ValueTracking.cpp:825
llvm::isGuaranteedNotToBeUndef
bool isGuaranteedNotToBeUndef(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Returns true if V cannot be undef, but may be poison.
Definition:ValueTracking.cpp:7856
llvm::computeConstantRange
ConstantRange computeConstantRange(const Value *V, bool ForSigned, bool UseInstrInfo=true, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Determine the possible constant range of an integer or vector of integer value.
Definition:ValueTracking.cpp:10078
llvm::MaskedValueIsZero
bool MaskedValueIsZero(const Value *V, const APInt &Mask, const SimplifyQuery &SQ, unsigned Depth=0)
Return true if 'V & Mask' is known to be zero.
Definition:ValueTracking.cpp:333
llvm::isOverflowIntrinsicNoWrap
bool isOverflowIntrinsicNoWrap(const WithOverflowInst *WO, const DominatorTree &DT)
Returns true if the arithmetic part of the WO 's result is used only along the paths control dependen...
Definition:ValueTracking.cpp:7387
llvm::matchSimpleRecurrence
bool matchSimpleRecurrence(const PHINode *P, BinaryOperator *&BO, Value *&Start, Value *&Step)
Attempt to match a simple first order recurrence cycle of the form: iv = phi Ty [Start,...
Definition:ValueTracking.cpp:9207
llvm::isSafeToSpeculativelyExecuteWithOpcode
bool isSafeToSpeculativelyExecuteWithOpcode(unsigned Opcode, const Instruction *Inst, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr, bool UseVariableInfo=true)
This returns the same result as isSafeToSpeculativelyExecute if Opcode is the actual opcode of Inst.
Definition:ValueTracking.cpp:7053
llvm::analyzeKnownBitsFromAndXorOr
KnownBits analyzeKnownBitsFromAndXorOr(const Operator *I, const KnownBits &KnownLHS, const KnownBits &KnownRHS, unsigned Depth, const SimplifyQuery &SQ)
Using KnownBits LHS/RHS produce the known bits for logic op (and/xor/or).
Definition:ValueTracking.cpp:1045
llvm::computeOverflowForUnsignedMul
OverflowResult computeOverflowForUnsignedMul(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ, bool IsNSW=false)
Definition:ValueTracking.cpp:7200
llvm::getInverseMinMaxFlavor
SelectPatternFlavor getInverseMinMaxFlavor(SelectPatternFlavor SPF)
Return the inverse minimum/maximum flavor of the specified flavor.
Definition:ValueTracking.cpp:9132
llvm::MaxAnalysisRecursionDepth
constexpr unsigned MaxAnalysisRecursionDepth
Definition:ValueTracking.h:44
llvm::isKnownNegative
bool isKnownNegative(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Returns true if the given value is known be negative (i.e.
Definition:ValueTracking.cpp:309
llvm::getGuaranteedWellDefinedOps
void getGuaranteedWellDefinedOps(const Instruction *I, SmallVectorImpl< const Value * > &Ops)
Insert operands of I into Ops such that I will trigger undefined behavior if I is executed and that o...
Definition:ValueTracking.cpp:8117
llvm::fneg
FPClassTest fneg(FPClassTest Mask)
Return the test mask which returns true if the value's sign bit is flipped.
Definition:FloatingPointMode.cpp:14
llvm::computeOverflowForSignedSub
OverflowResult computeOverflowForSignedSub(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
Definition:ValueTracking.cpp:7358
llvm::fcmpImpliesClass
std::tuple< Value *, FPClassTest, FPClassTest > fcmpImpliesClass(CmpInst::Predicate Pred, const Function &F, Value *LHS, Value *RHS, bool LookThroughSrc=true)
Compute the possible floating-point classes that LHS could be based on fcmp \Pred LHS,...
Definition:ValueTracking.cpp:4922
llvm::SelectPatternFlavor
SelectPatternFlavor
Specific patterns of select instructions we can match.
Definition:ValueTracking.h:1113
llvm::SPF_ABS
@ SPF_ABS
Floating point maxnum.
Definition:ValueTracking.h:1121
llvm::SPF_NABS
@ SPF_NABS
Absolute value.
Definition:ValueTracking.h:1122
llvm::SPF_FMAXNUM
@ SPF_FMAXNUM
Floating point minnum.
Definition:ValueTracking.h:1120
llvm::SPF_UMIN
@ SPF_UMIN
Signed minimum.
Definition:ValueTracking.h:1116
llvm::SPF_UMAX
@ SPF_UMAX
Signed maximum.
Definition:ValueTracking.h:1118
llvm::SPF_SMIN
@ SPF_SMIN
Definition:ValueTracking.h:1115
llvm::SPF_SMAX
@ SPF_SMAX
Unsigned minimum.
Definition:ValueTracking.h:1117
llvm::SPF_UNKNOWN
@ SPF_UNKNOWN
Definition:ValueTracking.h:1114
llvm::SPF_FMINNUM
@ SPF_FMINNUM
Unsigned maximum.
Definition:ValueTracking.h:1119
llvm::isIntrinsicReturningPointerAliasingArgumentWithoutCapturing
bool isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(const CallBase *Call, bool MustPreserveNullness)
{launder,strip}.invariant.group returns pointer that aliases its argument, and it only captures point...
Definition:ValueTracking.cpp:6712
llvm::adjustKnownBitsForSelectArm
void adjustKnownBitsForSelectArm(KnownBits &Known, Value *Cond, Value *Arm, bool Invert, unsigned Depth, const SimplifyQuery &Q)
Adjust Known for the given select Arm to include information from the select Cond.
Definition:ValueTracking.cpp:1077
llvm::impliesPoison
bool impliesPoison(const Value *ValAssumedPoison, const Value *V)
Return true if V is poison given that ValAssumedPoison is already poison.
Definition:ValueTracking.cpp:7690
llvm::getSelectPattern
SelectPatternResult getSelectPattern(CmpInst::Predicate Pred, SelectPatternNaNBehavior NaNBehavior=SPNB_NA, bool Ordered=false)
Determine the pattern for predicate X Pred Y ? X : Y.
Definition:ValueTracking.cpp:8633
llvm::FPClassTest
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
Definition:FloatingPointMode.h:239
llvm::fcInf
@ fcInf
Definition:FloatingPointMode.h:254
llvm::fcNegSubnormal
@ fcNegSubnormal
Definition:FloatingPointMode.h:246
llvm::fcPosNormal
@ fcPosNormal
Definition:FloatingPointMode.h:250
llvm::fcNegZero
@ fcNegZero
Definition:FloatingPointMode.h:247
llvm::fcNegInf
@ fcNegInf
Definition:FloatingPointMode.h:244
llvm::fcSubnormal
@ fcSubnormal
Definition:FloatingPointMode.h:256
llvm::fcNone
@ fcNone
Definition:FloatingPointMode.h:240
llvm::fcPositive
@ fcPositive
Definition:FloatingPointMode.h:261
llvm::fcPosZero
@ fcPosZero
Definition:FloatingPointMode.h:248
llvm::fcSNan
@ fcSNan
Definition:FloatingPointMode.h:242
llvm::fcNegNormal
@ fcNegNormal
Definition:FloatingPointMode.h:245
llvm::fcZero
@ fcZero
Definition:FloatingPointMode.h:257
llvm::fcNegative
@ fcNegative
Definition:FloatingPointMode.h:262
llvm::fcAllFlags
@ fcAllFlags
Definition:FloatingPointMode.h:264
llvm::fcPosSubnormal
@ fcPosSubnormal
Definition:FloatingPointMode.h:249
llvm::fcPosInf
@ fcPosInf
Definition:FloatingPointMode.h:251
llvm::fcNormal
@ fcNormal
Definition:FloatingPointMode.h:255
llvm::fcNan
@ fcNan
Definition:FloatingPointMode.h:253
llvm::programUndefinedIfPoison
bool programUndefinedIfPoison(const Instruction *Inst)
Definition:ValueTracking.cpp:8259
llvm::matchSelectPattern
SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
Definition:ValueTracking.cpp:9047
llvm::programUndefinedIfUndefOrPoison
bool programUndefinedIfUndefOrPoison(const Instruction *Inst)
Return true if this function can prove that if Inst is executed and yields a poison value or undef bi...
Definition:ValueTracking.cpp:8255
llvm::isSafeToSpeculativelyExecute
bool isSafeToSpeculativelyExecute(const Instruction *I, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr, bool UseVariableInfo=true)
Return true if the instruction does not have any effects besides calculating the result and does not ...
Definition:ValueTracking.cpp:7043
llvm::GetStringLength
uint64_t GetStringLength(const Value *V, unsigned CharSize=8)
If we can compute the length of the string pointed to by the specified pointer, return 'len+1'.
Definition:ValueTracking.cpp:6687
llvm::computeOverflowForSignedMul
OverflowResult computeOverflowForSignedMul(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
Definition:ValueTracking.cpp:7216
llvm::getVScaleRange
ConstantRange getVScaleRange(const Function *F, unsigned BitWidth)
Determine the possible constant range of vscale with the given bit width, based on the vscale_range f...
Definition:ValueTracking.cpp:1058
llvm::canCreateUndefOrPoison
bool canCreateUndefOrPoison(const Operator *Op, bool ConsiderFlagsAndMetadata=true)
canCreateUndefOrPoison returns true if Op can create undef or poison from non-undef & non-poison oper...
Definition:ValueTracking.cpp:7630
llvm::isKnownInversion
bool isKnownInversion(const Value *X, const Value *Y)
Return true iff:
Definition:ValueTracking.cpp:8602
llvm::isNotCrossLaneOperation
bool isNotCrossLaneOperation(const Instruction *I)
Return true if the instruction doesn't potentially cross vector lanes.
Definition:ValueTracking.cpp:7035
llvm::isKnownNonZero
bool isKnownNonZero(const Value *V, const SimplifyQuery &Q, unsigned Depth=0)
Return true if the given value is known to be non-zero when defined.
Definition:ValueTracking.cpp:3487
llvm::onlyUsedByLifetimeMarkers
bool onlyUsedByLifetimeMarkers(const Value *V)
Return true if the only users of this pointer are lifetime markers.
Definition:ValueTracking.cpp:7026
llvm::getIntrinsicForCallSite
Intrinsic::ID getIntrinsicForCallSite(const CallBase &CB, const TargetLibraryInfo *TLI)
Map a call instruction to an intrinsic ID.
Definition:ValueTracking.cpp:4245
llvm::IRMemLocation::Other
@ Other
Any other memory.
llvm::getUnderlyingObjectAggressive
const Value * getUnderlyingObjectAggressive(const Value *V)
Like getUnderlyingObject(), but will try harder to find a single underlying object.
Definition:ValueTracking.cpp:6857
llvm::getMinMaxIntrinsic
Intrinsic::ID getMinMaxIntrinsic(SelectPatternFlavor SPF)
Convert given SPF to equivalent min/max intrinsic.
Definition:ValueTracking.cpp:9117
llvm::computeOverflowForSignedAdd
OverflowResult computeOverflowForSignedAdd(const WithCache< const Value * > &LHS, const WithCache< const Value * > &RHS, const SimplifyQuery &SQ)
Definition:ValueTracking.cpp:7914
llvm::propagatesPoison
bool propagatesPoison(const Use &PoisonOp)
Return true if PoisonOp's user yields poison or raises UB if its operand PoisonOp is poison.
Definition:ValueTracking.cpp:7997
llvm::isKnownNonEqual
bool isKnownNonEqual(const Value *V1, const Value *V2, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if the given values are known to be non-equal when defined.
Definition:ValueTracking.cpp:318
llvm::RecurKind::Add
@ Add
Sum of integers.
llvm::computeConstantRangeIncludingKnownBits
ConstantRange computeConstantRangeIncludingKnownBits(const WithCache< const Value * > &V, bool ForSigned, const SimplifyQuery &SQ)
Combine constant ranges from computeConstantRange() and computeKnownBits().
Definition:ValueTracking.cpp:7189
llvm::SelectPatternNaNBehavior
SelectPatternNaNBehavior
Behavior when a floating point min/max is given one NaN and one non-NaN as input.
Definition:ValueTracking.h:1127
llvm::SPNB_RETURNS_NAN
@ SPNB_RETURNS_NAN
NaN behavior not applicable.
Definition:ValueTracking.h:1129
llvm::SPNB_RETURNS_OTHER
@ SPNB_RETURNS_OTHER
Given one NaN input, returns the NaN.
Definition:ValueTracking.h:1130
llvm::SPNB_RETURNS_ANY
@ SPNB_RETURNS_ANY
Given one NaN input, returns the non-NaN.
Definition:ValueTracking.h:1131
llvm::SPNB_NA
@ SPNB_NA
Definition:ValueTracking.h:1128
llvm::computeKnownBits
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
Definition:ValueTracking.cpp:164
llvm::Op
DWARFExpression::Operation Op
Definition:DWARFExpression.cpp:22
llvm::isGuaranteedNotToBeUndefOrPoison
bool isGuaranteedNotToBeUndefOrPoison(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Return true if this function can prove that V does not have undef bits and is never poison.
Definition:ValueTracking.cpp:7841
llvm::ArrayRef
ArrayRef(const T &OneElt) -> ArrayRef< T >
llvm::BitWidth
constexpr unsigned BitWidth
Definition:BitmaskEnum.h:217
llvm::matchDecomposedSelectPattern
SelectPatternResult matchDecomposedSelectPattern(CmpInst *CmpI, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
Determine the pattern that a select with the given compare as its predicate and given values as its t...
Definition:ValueTracking.cpp:9066
llvm::computeOverflowForUnsignedSub
OverflowResult computeOverflowForUnsignedSub(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
Definition:ValueTracking.cpp:7325
llvm::isGuaranteedToTransferExecutionToSuccessor
bool isGuaranteedToTransferExecutionToSuccessor(const Instruction *I)
Return true if this function can prove that the instruction I will always transfer execution to one o...
Definition:ValueTracking.cpp:7920
llvm::fcmpToClassTest
std::pair< Value *, FPClassTest > fcmpToClassTest(CmpInst::Predicate Pred, const Function &F, Value *LHS, Value *RHS, bool LookThroughSrc=true)
Returns a pair of values, which if passed to llvm.is.fpclass, returns the same result as an fcmp with...
Definition:ValueTracking.cpp:4519
llvm::isBytewiseValue
Value * isBytewiseValue(Value *V, const DataLayout &DL)
If the specified value can be set by repeating the same byte in memory, return the i8 value that it i...
Definition:ValueTracking.cpp:6189
llvm::getFlippedStrictnessPredicateAndConstant
std::optional< std::pair< CmpPredicate, Constant * > > getFlippedStrictnessPredicateAndConstant(CmpPredicate Pred, Constant *C)
Convert an integer comparison with a constant RHS into an equivalent form with the strictness flipped...
Definition:ValueTracking.cpp:8665
llvm::getUnderlyingObjects
void getUnderlyingObjects(const Value *V, SmallVectorImpl< const Value * > &Objects, const LoopInfo *LI=nullptr, unsigned MaxLookup=6)
This method is similar to getUnderlyingObject except that it can look through phi and select instruct...
Definition:ValueTracking.cpp:6815
llvm::computeKnownFPSignBit
std::optional< bool > computeKnownFPSignBit(const Value *V, unsigned Depth, const SimplifyQuery &SQ)
Return false if we can prove that the specified FP value's sign bit is 0.
Definition:ValueTracking.h:610
llvm::cannotBeOrderedLessThanZero
bool cannotBeOrderedLessThanZero(const Value *V, unsigned Depth, const SimplifyQuery &SQ)
Return true if we can prove that the specified FP value is either NaN or never less than -0....
Definition:ValueTracking.h:575
llvm::ComputeNumSignBits
unsigned ComputeNumSignBits(const Value *Op, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return the number of times the sign bit of the register is replicated into the other bits.
Definition:ValueTracking.cpp:351
llvm::cannotBeNegativeZero
bool cannotBeNegativeZero(const Value *V, unsigned Depth, const SimplifyQuery &SQ)
Return true if we can prove that the specified FP value is never equal to -0.0.
Definition:ValueTracking.h:561
llvm::computeOverflowForUnsignedAdd
OverflowResult computeOverflowForUnsignedAdd(const WithCache< const Value * > &LHS, const WithCache< const Value * > &RHS, const SimplifyQuery &SQ)
Definition:ValueTracking.cpp:7256
llvm::isKnownNeverNaN
bool isKnownNeverNaN(const Value *V, unsigned Depth, const SimplifyQuery &SQ)
Return true if the floating-point scalar value is not a NaN or if the floating-point vector value has...
Definition:ValueTracking.h:601
llvm::isImpliedByDomCondition
std::optional< bool > isImpliedByDomCondition(const Value *Cond, const Instruction *ContextI, const DataLayout &DL)
Return the boolean condition value in the context of the given instruction if it is known based on do...
Definition:ValueTracking.cpp:9680
llvm::isGEPBasedOnPointerToString
bool isGEPBasedOnPointerToString(const GEPOperator *GEP, unsigned CharSize=8)
Returns true if the GEP is based on a pointer to a string (array of.
Definition:ValueTracking.cpp:6455
llvm::operator|
APInt operator|(APInt a, const APInt &b)
Definition:APInt.h:2112
llvm::isGuaranteedNotToBePoison
bool isGuaranteedNotToBePoison(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Returns true if V cannot be poison, but may be undef.
Definition:ValueTracking.cpp:7849
llvm::computeKnownFPClass
KnownFPClass computeKnownFPClass(const Value *V, const APInt &DemandedElts, FPClassTest InterestedClasses, unsigned Depth, const SimplifyQuery &SQ)
Determine which floating-point classes are valid for V, and return them in KnownFPClass bit sets.
Definition:ValueTracking.cpp:6169
llvm::computeKnownBitsFromRangeMetadata
void computeKnownBitsFromRangeMetadata(const MDNode &Ranges, KnownBits &Known)
Compute known bits from the range metadata.
Definition:ValueTracking.cpp:439
llvm::FindInsertedValue
Value * FindInsertedValue(Value *V, ArrayRef< unsigned > idx_range, std::optional< BasicBlock::iterator > InsertBefore=std::nullopt)
Given an aggregate and an sequence of indices, see if the scalar value indexed is already around as a...
Definition:ValueTracking.cpp:6372
llvm::isKnownNegation
bool isKnownNegation(const Value *X, const Value *Y, bool NeedNSW=false, bool AllowPoison=true)
Return true if the two given values are negation.
Definition:ValueTracking.cpp:8571
llvm::isKnownPositive
bool isKnownPositive(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Returns true if the given value is known be positive (i.e.
Definition:ValueTracking.cpp:297
llvm::isKnownNonNegative
bool isKnownNonNegative(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Returns true if the give value is known to be non-negative.
Definition:ValueTracking.cpp:292
llvm::ComputeMaxSignificantBits
unsigned ComputeMaxSignificantBits(const Value *Op, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Get the upper bound on bit size for this Value Op as a signed integer.
Definition:ValueTracking.cpp:359
llvm::mayHaveNonDefUseDependency
bool mayHaveNonDefUseDependency(const Instruction &I)
Returns true if the result or effects of the given instructions I depend values not reachable through...
Definition:ValueTracking.cpp:7156
llvm::isImpliedCondition
std::optional< bool > isImpliedCondition(const Value *LHS, const Value *RHS, const DataLayout &DL, bool LHSIsTrue=true, unsigned Depth=0)
Return true if RHS is known to be implied true by LHS.
Definition:ValueTracking.cpp:9596
llvm::findValuesAffectedByCondition
void findValuesAffectedByCondition(Value *Cond, bool IsAssume, function_ref< void(Value *)> InsertAffected)
Call InsertAffected on all Values whose known bits / value may be affected by the condition Cond.
Definition:ValueTracking.cpp:10176
llvm::ConstantDataArraySlice
Represents offset+length into a ConstantDataArray.
Definition:ValueTracking.h:662
llvm::ConstantDataArraySlice::Length
uint64_t Length
Length of the slice.
Definition:ValueTracking.h:671
llvm::ConstantDataArraySlice::Offset
uint64_t Offset
Slice starts at this Offset.
Definition:ValueTracking.h:668
llvm::ConstantDataArraySlice::operator[]
uint64_t operator[](unsigned I) const
Convenience accessor for elements in the slice.
Definition:ValueTracking.h:681
llvm::ConstantDataArraySlice::move
void move(uint64_t Delta)
Moves the Offset and adjusts Length accordingly.
Definition:ValueTracking.h:674
llvm::ConstantDataArraySlice::Array
const ConstantDataArray * Array
ConstantDataArray pointer.
Definition:ValueTracking.h:665
llvm::KnownBits
Definition:KnownBits.h:23
llvm::KnownFPClass
Definition:ValueTracking.h:261
llvm::KnownFPClass::isKnownAlwaysNaN
bool isKnownAlwaysNaN() const
Return true if it's known this must always be a nan.
Definition:ValueTracking.h:290
llvm::KnownFPClass::KnownFPClasses
FPClassTest KnownFPClasses
Floating-point classes the value could be one of.
Definition:ValueTracking.h:263
llvm::KnownFPClass::isKnownNeverInfinity
bool isKnownNeverInfinity() const
Return true if it's known this can never be an infinity.
Definition:ValueTracking.h:293
llvm::KnownFPClass::cannotBeOrderedGreaterThanZero
bool cannotBeOrderedGreaterThanZero() const
Return true if we can prove that the analyzed floating-point value is either NaN or never greater tha...
Definition:ValueTracking.h:374
llvm::KnownFPClass::resetAll
void resetAll()
Definition:ValueTracking.h:486
llvm::KnownFPClass::OrderedGreaterThanZeroMask
static constexpr FPClassTest OrderedGreaterThanZeroMask
Definition:ValueTracking.h:352
llvm::KnownFPClass::OrderedLessThanZeroMask
static constexpr FPClassTest OrderedLessThanZeroMask
Definition:ValueTracking.h:350
llvm::KnownFPClass::knownNot
void knownNot(FPClassTest RuleOut)
Definition:ValueTracking.h:386
llvm::KnownFPClass::isKnownNeverZero
bool isKnownNeverZero() const
Return true if it's known this can never be a zero.
Definition:ValueTracking.h:324
llvm::KnownFPClass::copysign
void copysign(const KnownFPClass &Sign)
Definition:ValueTracking.h:435
llvm::KnownFPClass::isKnownNeverSubnormal
bool isKnownNeverSubnormal() const
Return true if it's known this can never be a subnormal.
Definition:ValueTracking.h:308
llvm::KnownFPClass::isKnownAlways
bool isKnownAlways(FPClassTest Mask) const
Definition:ValueTracking.h:278
llvm::KnownFPClass::isKnownNeverLogicalNegZero
bool isKnownNeverLogicalNegZero(const Function &F, Type *Ty) const
Return true if it's know this can never be interpreted as a negative zero.
Definition:ValueTracking.cpp:4412
llvm::KnownFPClass::isKnownNeverLogicalPosZero
bool isKnownNeverLogicalPosZero(const Function &F, Type *Ty) const
Return true if it's know this can never be interpreted as a positive zero.
Definition:ValueTracking.cpp:4418
llvm::KnownFPClass::operator|=
KnownFPClass & operator|=(const KnownFPClass &RHS)
Definition:ValueTracking.h:378
llvm::KnownFPClass::fneg
void fneg()
Definition:ValueTracking.h:396
llvm::KnownFPClass::propagateCanonicalizingSrc
void propagateCanonicalizingSrc(const KnownFPClass &Src, const Function &F, Type *Ty)
Report known classes if Src is evaluated through a potentially canonicalizing operation.
Definition:ValueTracking.cpp:4472
llvm::KnownFPClass::propagateDenormal
void propagateDenormal(const KnownFPClass &Src, const Function &F, Type *Ty)
Propagate knowledge from a source value that could be a denormal or zero.
Definition:ValueTracking.cpp:4443
llvm::KnownFPClass::isUnknown
bool isUnknown() const
Definition:ValueTracking.h:280
llvm::KnownFPClass::isKnownNeverNegInfinity
bool isKnownNeverNegInfinity() const
Return true if it's known this can never be -infinity.
Definition:ValueTracking.h:303
llvm::KnownFPClass::isKnownNeverNegSubnormal
bool isKnownNeverNegSubnormal() const
Return true if it's known this can never be a negative subnormal.
Definition:ValueTracking.h:318
llvm::KnownFPClass::isKnownNeverPosZero
bool isKnownNeverPosZero() const
Return true if it's known this can never be a literal positive zero.
Definition:ValueTracking.h:329
llvm::KnownFPClass::SignBit
std::optional< bool > SignBit
std::nullopt if the sign bit is unknown, true if the sign bit is definitely set or false if the sign ...
Definition:ValueTracking.h:267
llvm::KnownFPClass::isKnownNeverNaN
bool isKnownNeverNaN() const
Return true if it's known this can never be a nan.
Definition:ValueTracking.h:285
llvm::KnownFPClass::isKnownNever
bool isKnownNever(FPClassTest Mask) const
Return true if it's known this can never be one of the mask entries.
Definition:ValueTracking.h:274
llvm::KnownFPClass::isKnownNeverNegZero
bool isKnownNeverNegZero() const
Return true if it's known this can never be a negative zero.
Definition:ValueTracking.h:335
llvm::KnownFPClass::isKnownNeverLogicalZero
bool isKnownNeverLogicalZero(const Function &F, Type *Ty) const
Return true if it's know this can never be interpreted as a zero.
Definition:ValueTracking.cpp:4407
llvm::KnownFPClass::propagateNaN
void propagateNaN(const KnownFPClass &Src, bool PreserveSign=false)
Definition:ValueTracking.h:460
llvm::KnownFPClass::cannotBeOrderedLessThanZero
bool cannotBeOrderedLessThanZero() const
Return true if we can prove that the analyzed floating-point value is either NaN or never less than -...
Definition:ValueTracking.h:363
llvm::KnownFPClass::signBitMustBeOne
void signBitMustBeOne()
Assume the sign bit is one.
Definition:ValueTracking.h:430
llvm::KnownFPClass::signBitMustBeZero
void signBitMustBeZero()
Assume the sign bit is zero.
Definition:ValueTracking.h:424
llvm::KnownFPClass::fabs
void fabs()
Definition:ValueTracking.h:402
llvm::KnownFPClass::isKnownNeverPosInfinity
bool isKnownNeverPosInfinity() const
Return true if it's known this can never be +infinity.
Definition:ValueTracking.h:298
llvm::KnownFPClass::operator==
bool operator==(KnownFPClass Other) const
Definition:ValueTracking.h:269
llvm::KnownFPClass::signBitIsZeroOrNaN
bool signBitIsZeroOrNaN() const
Return true if the sign bit must be 0, ignoring the sign of nans.
Definition:ValueTracking.h:419
llvm::KnownFPClass::isKnownNeverPosSubnormal
bool isKnownNeverPosSubnormal() const
Return true if it's known this can never be a positive subnormal.
Definition:ValueTracking.h:313
llvm::SelectPatternResult
Definition:ValueTracking.h:1136
llvm::SelectPatternResult::Flavor
SelectPatternFlavor Flavor
Definition:ValueTracking.h:1137
llvm::SelectPatternResult::Ordered
bool Ordered
Only applicable if Flavor is SPF_FMINNUM or SPF_FMAXNUM.
Definition:ValueTracking.h:1140
llvm::SelectPatternResult::isMinOrMax
static bool isMinOrMax(SelectPatternFlavor SPF)
When implementing this min/max pattern as fcmp; select, does the fcmp have to be ordered?
Definition:ValueTracking.h:1145
llvm::SelectPatternResult::NaNBehavior
SelectPatternNaNBehavior NaNBehavior
Definition:ValueTracking.h:1138
llvm::SimplifyQuery
Definition:SimplifyQuery.h:70

Generated on Thu Jul 17 2025 09:32:34 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp