LLVM  13.0.0git
KnownBits.h
Go to the documentation of this file.
1 //===- llvm/Support/KnownBits.h - Stores known zeros/ones -------*- 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 a class for representing known zeros and ones used by
10 // computeKnownBits.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_KNOWNBITS_H
15 #define LLVM_SUPPORT_KNOWNBITS_H
16 
17 #include "llvm/ADT/APInt.h"
18 #include "llvm/ADT/Optional.h"
19 
20 namespace llvm {
21 
22 // Struct for tracking the known zeros and ones of a value.
23 struct KnownBits {
26 
27 private:
28  // Internal constructor for creating a KnownBits from two APInts.
30  : Zero(std::move(Zero)), One(std::move(One)) {}
31 
32 public:
33  // Default construct Zero and One.
34  KnownBits() {}
35 
36  /// Create a known bits object of BitWidth bits initialized to unknown.
37  KnownBits(unsigned BitWidth) : Zero(BitWidth, 0), One(BitWidth, 0) {}
38 
39  /// Get the bit width of this value.
40  unsigned getBitWidth() const {
42  "Zero and One should have the same width!");
43  return Zero.getBitWidth();
44  }
45 
46  /// Returns true if there is conflicting information.
47  bool hasConflict() const { return Zero.intersects(One); }
48 
49  /// Returns true if we know the value of all bits.
50  bool isConstant() const {
51  assert(!hasConflict() && "KnownBits conflict!");
53  }
54 
55  /// Returns the value when all bits have a known value. This just returns One
56  /// with a protective assertion.
57  const APInt &getConstant() const {
58  assert(isConstant() && "Can only get value when all bits are known");
59  return One;
60  }
61 
62  /// Returns true if we don't know any bits.
63  bool isUnknown() const { return Zero.isNullValue() && One.isNullValue(); }
64 
65  /// Resets the known state of all bits.
66  void resetAll() {
68  One.clearAllBits();
69  }
70 
71  /// Returns true if value is all zero.
72  bool isZero() const {
73  assert(!hasConflict() && "KnownBits conflict!");
74  return Zero.isAllOnesValue();
75  }
76 
77  /// Returns true if value is all one bits.
78  bool isAllOnes() const {
79  assert(!hasConflict() && "KnownBits conflict!");
80  return One.isAllOnesValue();
81  }
82 
83  /// Make all bits known to be zero and discard any previous information.
84  void setAllZero() {
85  Zero.setAllBits();
86  One.clearAllBits();
87  }
88 
89  /// Make all bits known to be one and discard any previous information.
90  void setAllOnes() {
92  One.setAllBits();
93  }
94 
95  /// Returns true if this value is known to be negative.
96  bool isNegative() const { return One.isSignBitSet(); }
97 
98  /// Returns true if this value is known to be non-negative.
99  bool isNonNegative() const { return Zero.isSignBitSet(); }
100 
101  /// Returns true if this value is known to be non-zero.
102  bool isNonZero() const { return !One.isNullValue(); }
103 
104  /// Returns true if this value is known to be positive.
105  bool isStrictlyPositive() const { return Zero.isSignBitSet() && !One.isNullValue(); }
106 
107  /// Make this value negative.
108  void makeNegative() {
109  One.setSignBit();
110  }
111 
112  /// Make this value non-negative.
114  Zero.setSignBit();
115  }
116 
117  /// Return the minimal unsigned value possible given these KnownBits.
118  APInt getMinValue() const {
119  // Assume that all bits that aren't known-ones are zeros.
120  return One;
121  }
122 
123  /// Return the minimal signed value possible given these KnownBits.
125  // Assume that all bits that aren't known-ones are zeros.
126  APInt Min = One;
127  // Sign bit is unknown.
128  if (Zero.isSignBitClear())
129  Min.setSignBit();
130  return Min;
131  }
132 
133  /// Return the maximal unsigned value possible given these KnownBits.
134  APInt getMaxValue() const {
135  // Assume that all bits that aren't known-zeros are ones.
136  return ~Zero;
137  }
138 
139  /// Return the maximal signed value possible given these KnownBits.
141  // Assume that all bits that aren't known-zeros are ones.
142  APInt Max = ~Zero;
143  // Sign bit is unknown.
144  if (One.isSignBitClear())
145  Max.clearSignBit();
146  return Max;
147  }
148 
149  /// Return known bits for a truncation of the value we're tracking.
150  KnownBits trunc(unsigned BitWidth) const {
152  }
153 
154  /// Return known bits for an "any" extension of the value we're tracking,
155  /// where we don't know anything about the extended bits.
156  KnownBits anyext(unsigned BitWidth) const {
158  }
159 
160  /// Return known bits for a zero extension of the value we're tracking.
161  KnownBits zext(unsigned BitWidth) const {
162  unsigned OldBitWidth = getBitWidth();
163  APInt NewZero = Zero.zext(BitWidth);
164  NewZero.setBitsFrom(OldBitWidth);
165  return KnownBits(NewZero, One.zext(BitWidth));
166  }
167 
168  /// Return known bits for a sign extension of the value we're tracking.
169  KnownBits sext(unsigned BitWidth) const {
171  }
172 
173  /// Return known bits for an "any" extension or truncation of the value we're
174  /// tracking.
175  KnownBits anyextOrTrunc(unsigned BitWidth) const {
176  if (BitWidth > getBitWidth())
177  return anyext(BitWidth);
178  if (BitWidth < getBitWidth())
179  return trunc(BitWidth);
180  return *this;
181  }
182 
183  /// Return known bits for a zero extension or truncation of the value we're
184  /// tracking.
185  KnownBits zextOrTrunc(unsigned BitWidth) const {
186  if (BitWidth > getBitWidth())
187  return zext(BitWidth);
188  if (BitWidth < getBitWidth())
189  return trunc(BitWidth);
190  return *this;
191  }
192 
193  /// Return known bits for a sign extension or truncation of the value we're
194  /// tracking.
195  KnownBits sextOrTrunc(unsigned BitWidth) const {
196  if (BitWidth > getBitWidth())
197  return sext(BitWidth);
198  if (BitWidth < getBitWidth())
199  return trunc(BitWidth);
200  return *this;
201  }
202 
203  /// Return known bits for a in-register sign extension of the value we're
204  /// tracking.
205  KnownBits sextInReg(unsigned SrcBitWidth) const;
206 
207  /// Return a KnownBits with the extracted bits
208  /// [bitPosition,bitPosition+numBits).
209  KnownBits extractBits(unsigned NumBits, unsigned BitPosition) const {
210  return KnownBits(Zero.extractBits(NumBits, BitPosition),
211  One.extractBits(NumBits, BitPosition));
212  }
213 
214  /// Return KnownBits based on this, but updated given that the underlying
215  /// value is known to be greater than or equal to Val.
216  KnownBits makeGE(const APInt &Val) const;
217 
218  /// Returns the minimum number of trailing zero bits.
219  unsigned countMinTrailingZeros() const {
220  return Zero.countTrailingOnes();
221  }
222 
223  /// Returns the minimum number of trailing one bits.
224  unsigned countMinTrailingOnes() const {
225  return One.countTrailingOnes();
226  }
227 
228  /// Returns the minimum number of leading zero bits.
229  unsigned countMinLeadingZeros() const {
230  return Zero.countLeadingOnes();
231  }
232 
233  /// Returns the minimum number of leading one bits.
234  unsigned countMinLeadingOnes() const {
235  return One.countLeadingOnes();
236  }
237 
238  /// Returns the number of times the sign bit is replicated into the other
239  /// bits.
240  unsigned countMinSignBits() const {
241  if (isNonNegative())
242  return countMinLeadingZeros();
243  if (isNegative())
244  return countMinLeadingOnes();
245  return 0;
246  }
247 
248  /// Returns the maximum number of trailing zero bits possible.
249  unsigned countMaxTrailingZeros() const {
250  return One.countTrailingZeros();
251  }
252 
253  /// Returns the maximum number of trailing one bits possible.
254  unsigned countMaxTrailingOnes() const {
255  return Zero.countTrailingZeros();
256  }
257 
258  /// Returns the maximum number of leading zero bits possible.
259  unsigned countMaxLeadingZeros() const {
260  return One.countLeadingZeros();
261  }
262 
263  /// Returns the maximum number of leading one bits possible.
264  unsigned countMaxLeadingOnes() const {
265  return Zero.countLeadingZeros();
266  }
267 
268  /// Returns the number of bits known to be one.
269  unsigned countMinPopulation() const {
270  return One.countPopulation();
271  }
272 
273  /// Returns the maximum number of bits that could be one.
274  unsigned countMaxPopulation() const {
275  return getBitWidth() - Zero.countPopulation();
276  }
277 
278  /// Create known bits from a known constant.
279  static KnownBits makeConstant(const APInt &C) {
280  return KnownBits(~C, C);
281  }
282 
283  /// Compute known bits common to LHS and RHS.
284  static KnownBits commonBits(const KnownBits &LHS, const KnownBits &RHS) {
285  return KnownBits(LHS.Zero & RHS.Zero, LHS.One & RHS.One);
286  }
287 
288  /// Return true if LHS and RHS have no common bits set.
289  static bool haveNoCommonBitsSet(const KnownBits &LHS, const KnownBits &RHS) {
290  return (LHS.Zero | RHS.Zero).isAllOnesValue();
291  }
292 
293  /// Compute known bits resulting from adding LHS, RHS and a 1-bit Carry.
295  const KnownBits &LHS, const KnownBits &RHS, const KnownBits &Carry);
296 
297  /// Compute known bits resulting from adding LHS and RHS.
298  static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS,
299  KnownBits RHS);
300 
301  /// Compute known bits resulting from multiplying LHS and RHS.
302  static KnownBits mul(const KnownBits &LHS, const KnownBits &RHS);
303 
304  /// Compute known bits from sign-extended multiply-hi.
305  static KnownBits mulhs(const KnownBits &LHS, const KnownBits &RHS);
306 
307  /// Compute known bits from zero-extended multiply-hi.
308  static KnownBits mulhu(const KnownBits &LHS, const KnownBits &RHS);
309 
310  /// Compute known bits for udiv(LHS, RHS).
311  static KnownBits udiv(const KnownBits &LHS, const KnownBits &RHS);
312 
313  /// Compute known bits for urem(LHS, RHS).
314  static KnownBits urem(const KnownBits &LHS, const KnownBits &RHS);
315 
316  /// Compute known bits for srem(LHS, RHS).
317  static KnownBits srem(const KnownBits &LHS, const KnownBits &RHS);
318 
319  /// Compute known bits for umax(LHS, RHS).
320  static KnownBits umax(const KnownBits &LHS, const KnownBits &RHS);
321 
322  /// Compute known bits for umin(LHS, RHS).
323  static KnownBits umin(const KnownBits &LHS, const KnownBits &RHS);
324 
325  /// Compute known bits for smax(LHS, RHS).
326  static KnownBits smax(const KnownBits &LHS, const KnownBits &RHS);
327 
328  /// Compute known bits for smin(LHS, RHS).
329  static KnownBits smin(const KnownBits &LHS, const KnownBits &RHS);
330 
331  /// Compute known bits for shl(LHS, RHS).
332  /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS.
333  static KnownBits shl(const KnownBits &LHS, const KnownBits &RHS);
334 
335  /// Compute known bits for lshr(LHS, RHS).
336  /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS.
337  static KnownBits lshr(const KnownBits &LHS, const KnownBits &RHS);
338 
339  /// Compute known bits for ashr(LHS, RHS).
340  /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS.
341  static KnownBits ashr(const KnownBits &LHS, const KnownBits &RHS);
342 
343  /// Determine if these known bits always give the same ICMP_EQ result.
344  static Optional<bool> eq(const KnownBits &LHS, const KnownBits &RHS);
345 
346  /// Determine if these known bits always give the same ICMP_NE result.
347  static Optional<bool> ne(const KnownBits &LHS, const KnownBits &RHS);
348 
349  /// Determine if these known bits always give the same ICMP_UGT result.
350  static Optional<bool> ugt(const KnownBits &LHS, const KnownBits &RHS);
351 
352  /// Determine if these known bits always give the same ICMP_UGE result.
353  static Optional<bool> uge(const KnownBits &LHS, const KnownBits &RHS);
354 
355  /// Determine if these known bits always give the same ICMP_ULT result.
356  static Optional<bool> ult(const KnownBits &LHS, const KnownBits &RHS);
357 
358  /// Determine if these known bits always give the same ICMP_ULE result.
359  static Optional<bool> ule(const KnownBits &LHS, const KnownBits &RHS);
360 
361  /// Determine if these known bits always give the same ICMP_SGT result.
362  static Optional<bool> sgt(const KnownBits &LHS, const KnownBits &RHS);
363 
364  /// Determine if these known bits always give the same ICMP_SGE result.
365  static Optional<bool> sge(const KnownBits &LHS, const KnownBits &RHS);
366 
367  /// Determine if these known bits always give the same ICMP_SLT result.
368  static Optional<bool> slt(const KnownBits &LHS, const KnownBits &RHS);
369 
370  /// Determine if these known bits always give the same ICMP_SLE result.
371  static Optional<bool> sle(const KnownBits &LHS, const KnownBits &RHS);
372 
373  /// Insert the bits from a smaller known bits starting at bitPosition.
374  void insertBits(const KnownBits &SubBits, unsigned BitPosition) {
375  Zero.insertBits(SubBits.Zero, BitPosition);
376  One.insertBits(SubBits.One, BitPosition);
377  }
378 
379  /// Return a subset of the known bits from [bitPosition,bitPosition+numBits).
380  KnownBits extractBits(unsigned NumBits, unsigned BitPosition) {
381  return KnownBits(Zero.extractBits(NumBits, BitPosition),
382  One.extractBits(NumBits, BitPosition));
383  }
384 
385  /// Update known bits based on ANDing with RHS.
386  KnownBits &operator&=(const KnownBits &RHS);
387 
388  /// Update known bits based on ORing with RHS.
389  KnownBits &operator|=(const KnownBits &RHS);
390 
391  /// Update known bits based on XORing with RHS.
392  KnownBits &operator^=(const KnownBits &RHS);
393 
394  /// Compute known bits for the absolute value.
395  KnownBits abs(bool IntMinIsPoison = false) const;
396 
398  return KnownBits(Zero.byteSwap(), One.byteSwap());
399  }
400 
403  }
404 
405  void print(raw_ostream &OS) const;
406  void dump() const;
407 };
408 
409 inline KnownBits operator&(KnownBits LHS, const KnownBits &RHS) {
410  LHS &= RHS;
411  return LHS;
412 }
413 
414 inline KnownBits operator&(const KnownBits &LHS, KnownBits &&RHS) {
415  RHS &= LHS;
416  return std::move(RHS);
417 }
418 
419 inline KnownBits operator|(KnownBits LHS, const KnownBits &RHS) {
420  LHS |= RHS;
421  return LHS;
422 }
423 
424 inline KnownBits operator|(const KnownBits &LHS, KnownBits &&RHS) {
425  RHS |= LHS;
426  return std::move(RHS);
427 }
428 
429 inline KnownBits operator^(KnownBits LHS, const KnownBits &RHS) {
430  LHS ^= RHS;
431  return LHS;
432 }
433 
434 inline KnownBits operator^(const KnownBits &LHS, KnownBits &&RHS) {
435  RHS ^= LHS;
436  return std::move(RHS);
437 }
438 
439 } // end namespace llvm
440 
441 #endif
llvm::KnownBits::anyext
KnownBits anyext(unsigned BitWidth) const
Return known bits for an "any" extension of the value we're tracking, where we don't know anything ab...
Definition: KnownBits.h:156
llvm::APInt::reverseBits
APInt reverseBits() const
Definition: APInt.cpp:691
llvm::KnownBits::shl
static KnownBits shl(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for shl(LHS, RHS).
Definition: KnownBits.cpp:167
llvm::APInt::setAllBits
void setAllBits()
Set every bit to 1.
Definition: APInt.h:1429
llvm::APInt::clearAllBits
void clearAllBits()
Set every bit to 0.
Definition: APInt.h:1515
llvm::KnownBits::lshr
static KnownBits lshr(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for lshr(LHS, RHS).
Definition: KnownBits.cpp:221
llvm::KnownBits::print
void print(raw_ostream &OS) const
Definition: KnownBits.cpp:608
llvm
Definition: AllocatorList.h:23
llvm::APInt::insertBits
void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
Definition: APInt.cpp:344
Optional.h
llvm::APInt::byteSwap
APInt byteSwap() const
Definition: APInt.cpp:669
llvm::KnownBits::trunc
KnownBits trunc(unsigned BitWidth) const
Return known bits for a truncation of the value we're tracking.
Definition: KnownBits.h:150
llvm::KnownBits::resetAll
void resetAll()
Resets the known state of all bits.
Definition: KnownBits.h:66
llvm::KnownBits::getMinValue
APInt getMinValue() const
Return the minimal unsigned value possible given these KnownBits.
Definition: KnownBits.h:118
llvm::KnownBits::insertBits
void insertBits(const KnownBits &SubBits, unsigned BitPosition)
Insert the bits from a smaller known bits starting at bitPosition.
Definition: KnownBits.h:374
llvm::KnownBits::byteSwap
KnownBits byteSwap()
Definition: KnownBits.h:397
llvm::KnownBits::Zero
APInt Zero
Definition: KnownBits.h:24
llvm::KnownBits::isUnknown
bool isUnknown() const
Returns true if we don't know any bits.
Definition: KnownBits.h:63
llvm::KnownBits::countMaxLeadingOnes
unsigned countMaxLeadingOnes() const
Returns the maximum number of leading one bits possible.
Definition: KnownBits.h:264
llvm::KnownBits::makeGE
KnownBits makeGE(const APInt &Val) const
Return KnownBits based on this, but updated given that the underlying value is known to be greater th...
Definition: KnownBits.cpp:105
llvm::KnownBits::anyextOrTrunc
KnownBits anyextOrTrunc(unsigned BitWidth) const
Return known bits for an "any" extension or truncation of the value we're tracking.
Definition: KnownBits.h:175
llvm::KnownBits::isNonZero
bool isNonZero() const
Returns true if this value is known to be non-zero.
Definition: KnownBits.h:102
llvm::KnownBits::ult
static Optional< bool > ult(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULT result.
Definition: KnownBits.cpp:363
APInt.h
llvm::KnownBits::getConstant
const APInt & getConstant() const
Returns the value when all bits have a known value.
Definition: KnownBits.h:57
llvm::APInt::getBitWidth
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1581
llvm::Optional< bool >
llvm::KnownBits::isZero
bool isZero() const
Returns true if value is all zero.
Definition: KnownBits.h:72
llvm::APInt::intersects
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
Definition: APInt.h:1341
llvm::APInt::countPopulation
unsigned countPopulation() const
Count the number of bits set.
Definition: APInt.h:1728
llvm::KnownBits::countMinTrailingZeros
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
Definition: KnownBits.h:219
llvm::KnownBits::makeNegative
void makeNegative()
Make this value negative.
Definition: KnownBits.h:108
llvm::KnownBits::isNonNegative
bool isNonNegative() const
Returns true if this value is known to be non-negative.
Definition: KnownBits.h:99
llvm::KnownBits::mulhu
static KnownBits mulhu(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits from zero-extended multiply-hi.
Definition: KnownBits.cpp:504
llvm::KnownBits::haveNoCommonBitsSet
static bool haveNoCommonBitsSet(const KnownBits &LHS, const KnownBits &RHS)
Return true if LHS and RHS have no common bits set.
Definition: KnownBits.h:289
llvm::KnownBits::operator&=
KnownBits & operator&=(const KnownBits &RHS)
Update known bits based on ANDing with RHS.
Definition: KnownBits.cpp:583
llvm::KnownBits::umax
static KnownBits umax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umax(LHS, RHS).
Definition: KnownBits.cpp:117
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::KnownBits::One
APInt One
Definition: KnownBits.h:25
llvm::KnownBits::smin
static KnownBits smin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smin(LHS, RHS).
Definition: KnownBits.cpp:154
llvm::KnownBits::hasConflict
bool hasConflict() const
Returns true if there is conflicting information.
Definition: KnownBits.h:47
llvm::KnownBits::abs
KnownBits abs(bool IntMinIsPoison=false) const
Compute known bits for the absolute value.
Definition: KnownBits.cpp:395
llvm::KnownBits::computeForAddCarry
static KnownBits computeForAddCarry(const KnownBits &LHS, const KnownBits &RHS, const KnownBits &Carry)
Compute known bits resulting from adding LHS, RHS and a 1-bit Carry.
Definition: KnownBits.cpp:50
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::APInt::isSignBitClear
bool isSignBitClear() const
Determine if sign bit of this APInt is clear.
Definition: APInt.h:383
llvm::KnownBits::isNegative
bool isNegative() const
Returns true if this value is known to be negative.
Definition: KnownBits.h:96
llvm::KnownBits::sext
KnownBits sext(unsigned BitWidth) const
Return known bits for a sign extension of the value we're tracking.
Definition: KnownBits.h:169
llvm::APInt::countTrailingZeros
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
Definition: APInt.h:1700
llvm::APInt::setSignBit
void setSignBit()
Set the sign bit to 1.
Definition: APInt.h:1452
llvm::APInt::isAllOnesValue
bool isAllOnesValue() const
Determine if all bits are set.
Definition: APInt.h:401
llvm::KnownBits::sle
static Optional< bool > sle(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLE result.
Definition: KnownBits.cpp:391
llvm::KnownBits::eq
static Optional< bool > eq(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_EQ result.
Definition: KnownBits.cpp:333
llvm::KnownBits::dump
void dump() const
Definition: KnownBits.cpp:611
llvm::KnownBits::uge
static Optional< bool > uge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGE result.
Definition: KnownBits.cpp:357
llvm::KnownBits::isAllOnes
bool isAllOnes() const
Returns true if value is all one bits.
Definition: KnownBits.h:78
llvm::KnownBits::reverseBits
KnownBits reverseBits()
Definition: KnownBits.h:401
llvm::KnownBits::operator|=
KnownBits & operator|=(const KnownBits &RHS)
Update known bits based on ORing with RHS.
Definition: KnownBits.cpp:591
llvm::operator|
APInt operator|(APInt a, const APInt &b)
Definition: APInt.h:2069
llvm::KnownBits::countMinLeadingOnes
unsigned countMinLeadingOnes() const
Returns the minimum number of leading one bits.
Definition: KnownBits.h:234
llvm::KnownBits::slt
static Optional< bool > slt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLT result.
Definition: KnownBits.cpp:387
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::KnownBits::extractBits
KnownBits extractBits(unsigned NumBits, unsigned BitPosition) const
Return a KnownBits with the extracted bits [bitPosition,bitPosition+numBits).
Definition: KnownBits.h:209
llvm::KnownBits::ule
static Optional< bool > ule(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULE result.
Definition: KnownBits.cpp:367
llvm::KnownBits::getMaxValue
APInt getMaxValue() const
Return the maximal unsigned value possible given these KnownBits.
Definition: KnownBits.h:134
llvm::KnownBits::countMaxLeadingZeros
unsigned countMaxLeadingZeros() const
Returns the maximum number of leading zero bits possible.
Definition: KnownBits.h:259
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::KnownBits::countMaxTrailingZeros
unsigned countMaxTrailingZeros() const
Returns the maximum number of trailing zero bits possible.
Definition: KnownBits.h:249
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1540
llvm::KnownBits::countMinLeadingZeros
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
Definition: KnownBits.h:229
llvm::APInt::extractBits
APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
Definition: APInt.cpp:426
llvm::KnownBits::countMinSignBits
unsigned countMinSignBits() const
Returns the number of times the sign bit is replicated into the other bits.
Definition: KnownBits.h:240
llvm::KnownBits::countMaxPopulation
unsigned countMaxPopulation() const
Returns the maximum number of bits that could be one.
Definition: KnownBits.h:274
llvm::KnownBits::urem
static KnownBits urem(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for urem(LHS, RHS).
Definition: KnownBits.cpp:531
llvm::KnownBits::KnownBits
KnownBits(unsigned BitWidth)
Create a known bits object of BitWidth bits initialized to unknown.
Definition: KnownBits.h:37
llvm::KnownBits::ashr
static KnownBits ashr(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for ashr(LHS, RHS).
Definition: KnownBits.cpp:274
llvm::KnownBits::computeForAddSub
static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS, KnownBits RHS)
Compute known bits resulting from adding LHS and RHS.
Definition: KnownBits.cpp:57
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:70
llvm::KnownBits::sextInReg
KnownBits sextInReg(unsigned SrcBitWidth) const
Return known bits for a in-register sign extension of the value we're tracking.
Definition: KnownBits.cpp:88
llvm::KnownBits::zext
KnownBits zext(unsigned BitWidth) const
Return known bits for a zero extension of the value we're tracking.
Definition: KnownBits.h:161
llvm::KnownBits::mul
static KnownBits mul(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits resulting from multiplying LHS and RHS.
Definition: KnownBits.cpp:415
llvm::KnownBits::smax
static KnownBits smax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smax(LHS, RHS).
Definition: KnownBits.cpp:141
llvm::APInt::zext
APInt zext(unsigned width) const
Zero extend to a new width.
Definition: APInt.cpp:930
llvm::operator^
APInt operator^(APInt a, const APInt &b)
Definition: APInt.h:2089
llvm::KnownBits::mulhs
static KnownBits mulhs(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits from sign-extended multiply-hi.
Definition: KnownBits.cpp:495
llvm::operator&
APInt operator&(APInt a, const APInt &b)
Definition: APInt.h:2049
llvm::KnownBits::ne
static Optional< bool > ne(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_NE result.
Definition: KnownBits.cpp:341
llvm::KnownBits::zextOrTrunc
KnownBits zextOrTrunc(unsigned BitWidth) const
Return known bits for a zero extension or truncation of the value we're tracking.
Definition: KnownBits.h:185
llvm::APInt::countLeadingZeros
unsigned countLeadingZeros() const
The APInt version of the countLeadingZeros functions in MathExtras.h.
Definition: APInt.h:1664
std
Definition: BitVector.h:838
llvm::APInt::trunc
APInt trunc(unsigned width) const
Truncate to new width.
Definition: APInt.cpp:858
llvm::KnownBits
Definition: KnownBits.h:23
llvm::KnownBits::udiv
static KnownBits udiv(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for udiv(LHS, RHS).
Definition: KnownBits.cpp:513
llvm::KnownBits::countMinPopulation
unsigned countMinPopulation() const
Returns the number of bits known to be one.
Definition: KnownBits.h:269
llvm::KnownBits::countMaxTrailingOnes
unsigned countMaxTrailingOnes() const
Returns the maximum number of trailing one bits possible.
Definition: KnownBits.h:254
llvm::BitWidth
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:147
llvm::KnownBits::setAllZero
void setAllZero()
Make all bits known to be zero and discard any previous information.
Definition: KnownBits.h:84
llvm::APInt::sext
APInt sext(unsigned width) const
Sign extend to a new width.
Definition: APInt.cpp:906
llvm::KnownBits::isStrictlyPositive
bool isStrictlyPositive() const
Returns true if this value is known to be positive.
Definition: KnownBits.h:105
llvm::APInt::isNullValue
bool isNullValue() const
Determine if all bits are clear.
Definition: APInt.h:411
llvm::KnownBits::getSignedMinValue
APInt getSignedMinValue() const
Return the minimal signed value possible given these KnownBits.
Definition: KnownBits.h:124
llvm::KnownBits::operator^=
KnownBits & operator^=(const KnownBits &RHS)
Update known bits based on XORing with RHS.
Definition: KnownBits.cpp:599
llvm::KnownBits::umin
static KnownBits umin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umin(LHS, RHS).
Definition: KnownBits.cpp:135
llvm::KnownBits::setAllOnes
void setAllOnes()
Make all bits known to be one and discard any previous information.
Definition: KnownBits.h:90
llvm::KnownBits::extractBits
KnownBits extractBits(unsigned NumBits, unsigned BitPosition)
Return a subset of the known bits from [bitPosition,bitPosition+numBits).
Definition: KnownBits.h:380
llvm::APInt::isSignBitSet
bool isSignBitSet() const
Determine if sign bit of this APInt is set.
Definition: APInt.h:376
llvm::APInt::countTrailingOnes
unsigned countTrailingOnes() const
Count the number of trailing one bits.
Definition: APInt.h:1716
llvm::KnownBits::commonBits
static KnownBits commonBits(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits common to LHS and RHS.
Definition: KnownBits.h:284
llvm::KnownBits::srem
static KnownBits srem(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for srem(LHS, RHS).
Definition: KnownBits.cpp:552
llvm::KnownBits::makeConstant
static KnownBits makeConstant(const APInt &C)
Create known bits from a known constant.
Definition: KnownBits.h:279
llvm::KnownBits::isConstant
bool isConstant() const
Returns true if we know the value of all bits.
Definition: KnownBits.h:50
llvm::KnownBits::sge
static Optional< bool > sge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGE result.
Definition: KnownBits.cpp:381
llvm::KnownBits::getSignedMaxValue
APInt getSignedMaxValue() const
Return the maximal signed value possible given these KnownBits.
Definition: KnownBits.h:140
llvm::KnownBits::KnownBits
KnownBits()
Definition: KnownBits.h:34
llvm::KnownBits::countMinTrailingOnes
unsigned countMinTrailingOnes() const
Returns the minimum number of trailing one bits.
Definition: KnownBits.h:224
llvm::KnownBits::getBitWidth
unsigned getBitWidth() const
Get the bit width of this value.
Definition: KnownBits.h:40
llvm::APInt::setBitsFrom
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
Definition: APInt.h:1500
llvm::KnownBits::ugt
static Optional< bool > ugt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGT result.
Definition: KnownBits.cpp:347
llvm::KnownBits::sextOrTrunc
KnownBits sextOrTrunc(unsigned BitWidth) const
Return known bits for a sign extension or truncation of the value we're tracking.
Definition: KnownBits.h:195
llvm::APInt::countLeadingOnes
unsigned countLeadingOnes() const
Count the number of leading one bits.
Definition: APInt.h:1680
llvm::KnownBits::makeNonNegative
void makeNonNegative()
Make this value non-negative.
Definition: KnownBits.h:113
llvm::KnownBits::sgt
static Optional< bool > sgt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGT result.
Definition: KnownBits.cpp:371