don't repeat function names in comments; NFC
gitsvnid: https://llvm.org/svn/llvmproject/llvm/trunk@275470 911773080d340410b5e696231b3b80d8
Sanjay Patel
4 years ago
21  21  
22  22  #define DEBUG_TYPE "instcombine" 
23  23  
24  /// ShrinkDemandedConstant  Check to see if the specified operand of the  
25  /// specified instruction is a constant integer. If so, check to see if there  
26  /// are any bits set in the constant that are not demanded. If so, shrink the  
27 
/// 

24  /// Check to see if the specified operand of the specified instruction is a⏎  
25  /// constant integer. If so, check to see if there are any bits set in the  
26  /// constant that are not demanded. If so, shrink the constant and return true.  
28  27  static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, 
29  28  APInt Demanded) { 
30  29  assert(I && "No instruction?"); 
48  47  
49  48  
50  49  
51  /// SimplifyDemandedInstructionBits  Inst is an integer instruction that  
52  /// SimplifyDemandedBits knows about. See if the instruction has any  
53 
/// 

50  /// Inst is an integer instruction that SimplifyDemandedBits knows about. See if⏎  
51  /// the instruction has any properties that allow us to simplify its operands.  
54  52  bool InstCombiner::SimplifyDemandedInstructionBits(Instruction &Inst) { 
55  53  unsigned BitWidth = Inst.getType()>getScalarSizeInBits(); 
56  54  APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0); 
64  62  return true; 
65  63  } 
66  64  
67  /// SimplifyDemandedBits  This form of SimplifyDemandedBits simplifies the  
68  /// specified instruction operand if possible, updating it in place. It returns  
69 
/// 

65  /// This form of SimplifyDemandedBits simplifies the specified instruction⏎  
66  /// operand if possible, updating it in place. It returns true if it made any  
67  /// change and false otherwise.  
70  68  bool InstCombiner::SimplifyDemandedBits(Use &U, const APInt &DemandedMask, 
71  69  APInt &KnownZero, APInt &KnownOne, 
72  70  unsigned Depth) { 
79  77  } 
80  78  
81  79  
82  /// SimplifyDemandedUseBits  This function attempts to replace V with a simpler  
83  /// value based on the demanded bits. When this function is called, it is known  
84  /// that only the bits set in DemandedMask of the result of V are ever used  
85  /// downstream. Consequently, depending on the mask and V, it may be possible  
86  /// to replace V with a constant or one of its operands. In such cases, this  
87  /// function does the replacement and returns true. In all other cases, it  
88  /// returns false after analyzing the expression and setting KnownOne and known  
89  /// to be one in the expression. KnownZero contains all the bits that are known  
90  /// to be zero in the expression. These are provided to potentially allow the  
91  /// caller (which might recursively be SimplifyDemandedBits itself) to simplify  
92  /// the expression. KnownOne and KnownZero always follow the invariant that  
93  /// KnownOne & KnownZero == 0. That is, a bit can't be both 1 and 0. Note that  
94  /// the bits in KnownOne and KnownZero may only be accurate for those bits set  
95  /// in DemandedMask. Note also that the bitwidth of V, DemandedMask, KnownZero  
96 
/// 

80  /// This function attempts to replace V with a simpler value based on the⏎  
81  /// demanded bits. When this function is called, it is known that only the bits  
82  /// set in DemandedMask of the result of V are ever used downstream.  
83  /// Consequently, depending on the mask and V, it may be possible to replace V  
84  /// with a constant or one of its operands. In such cases, this function does  
85  /// the replacement and returns true. In all other cases, it returns false after  
86  /// analyzing the expression and setting KnownOne and known to be one in the  
87  /// expression. KnownZero contains all the bits that are known to be zero in the  
88  /// expression. These are provided to potentially allow the caller (which might  
89  /// recursively be SimplifyDemandedBits itself) to simplify the expression.  
90  /// KnownOne and KnownZero always follow the invariant that:  
91  /// KnownOne & KnownZero == 0.  
92  /// That is, a bit can't be both 1 and 0. Note that the bits in KnownOne and  
93  /// KnownZero may only be accurate for those bits set in DemandedMask. Note also  
94  /// that the bitwidth of V, DemandedMask, KnownZero and KnownOne must all be the  
95  /// same.  
97  96  /// 
98  97  /// This returns null if it did not change anything and it permits no 
99  98  /// simplification. This returns V itself if it did some simplification of V's 
895  894  return nullptr; 
896  895  } 
897  896  
898  /// SimplifyDemandedVectorElts  The specified value produces a vector with  
899  /// any number of elements. DemandedElts contains the set of elements that are  
900  /// actually used by the caller. This method analyzes which elements of the  
901 
/// 

897  /// The specified value produces a vector with any number of elements.⏎  
898  /// DemandedElts contains the set of elements that are actually used by the  
899  /// caller. This method analyzes which elements of the operand are undef and  
900  /// returns that information in UndefElts.  
902  901  /// 
903  902  /// If the information about demanded elements can be used to simplify the 
904  903  /// operation, the operation is simplified, then the resultant value is 