InstCombiner.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- InstCombiner.h - InstCombine implementation --------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. /// \file
  14. ///
  15. /// This file provides the interface for the instcombine pass implementation.
  16. /// The interface is used for generic transformations in this folder and
  17. /// target specific combinations in the targets.
  18. /// The visitor implementation is in \c InstCombinerImpl in
  19. /// \c InstCombineInternal.h.
  20. ///
  21. //===----------------------------------------------------------------------===//
  22. #ifndef LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINER_H
  23. #define LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINER_H
  24. #include "llvm/Analysis/InstructionSimplify.h"
  25. #include "llvm/Analysis/TargetFolder.h"
  26. #include "llvm/Analysis/ValueTracking.h"
  27. #include "llvm/IR/IRBuilder.h"
  28. #include "llvm/IR/PatternMatch.h"
  29. #include "llvm/Support/Debug.h"
  30. #include "llvm/Support/KnownBits.h"
  31. #include <cassert>
  32. #define DEBUG_TYPE "instcombine"
  33. #include "llvm/Transforms/Utils/InstructionWorklist.h"
  34. namespace llvm {
  35. class AAResults;
  36. class AssumptionCache;
  37. class ProfileSummaryInfo;
  38. class TargetLibraryInfo;
  39. class TargetTransformInfo;
  40. /// The core instruction combiner logic.
  41. ///
  42. /// This class provides both the logic to recursively visit instructions and
  43. /// combine them.
  44. class LLVM_LIBRARY_VISIBILITY InstCombiner {
  45. /// Only used to call target specific intrinsic combining.
  46. /// It must **NOT** be used for any other purpose, as InstCombine is a
  47. /// target-independent canonicalization transform.
  48. TargetTransformInfo &TTI;
  49. public:
  50. /// Maximum size of array considered when transforming.
  51. uint64_t MaxArraySizeForCombine = 0;
  52. /// An IRBuilder that automatically inserts new instructions into the
  53. /// worklist.
  54. using BuilderTy = IRBuilder<TargetFolder, IRBuilderCallbackInserter>;
  55. BuilderTy &Builder;
  56. protected:
  57. /// A worklist of the instructions that need to be simplified.
  58. InstructionWorklist &Worklist;
  59. // Mode in which we are running the combiner.
  60. const bool MinimizeSize;
  61. AAResults *AA;
  62. // Required analyses.
  63. AssumptionCache &AC;
  64. TargetLibraryInfo &TLI;
  65. DominatorTree &DT;
  66. const DataLayout &DL;
  67. const SimplifyQuery SQ;
  68. OptimizationRemarkEmitter &ORE;
  69. BlockFrequencyInfo *BFI;
  70. ProfileSummaryInfo *PSI;
  71. // Optional analyses. When non-null, these can both be used to do better
  72. // combining and will be updated to reflect any changes.
  73. LoopInfo *LI;
  74. bool MadeIRChange = false;
  75. public:
  76. InstCombiner(InstructionWorklist &Worklist, BuilderTy &Builder,
  77. bool MinimizeSize, AAResults *AA, AssumptionCache &AC,
  78. TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
  79. DominatorTree &DT, OptimizationRemarkEmitter &ORE,
  80. BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI,
  81. const DataLayout &DL, LoopInfo *LI)
  82. : TTI(TTI), Builder(Builder), Worklist(Worklist),
  83. MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
  84. SQ(DL, &TLI, &DT, &AC), ORE(ORE), BFI(BFI), PSI(PSI), LI(LI) {}
  85. virtual ~InstCombiner() = default;
  86. /// Return the source operand of a potentially bitcasted value while
  87. /// optionally checking if it has one use. If there is no bitcast or the one
  88. /// use check is not met, return the input value itself.
  89. static Value *peekThroughBitcast(Value *V, bool OneUseOnly = false) {
  90. if (auto *BitCast = dyn_cast<BitCastInst>(V))
  91. if (!OneUseOnly || BitCast->hasOneUse())
  92. return BitCast->getOperand(0);
  93. // V is not a bitcast or V has more than one use and OneUseOnly is true.
  94. return V;
  95. }
  96. /// Assign a complexity or rank value to LLVM Values. This is used to reduce
  97. /// the amount of pattern matching needed for compares and commutative
  98. /// instructions. For example, if we have:
  99. /// icmp ugt X, Constant
  100. /// or
  101. /// xor (add X, Constant), cast Z
  102. ///
  103. /// We do not have to consider the commuted variants of these patterns because
  104. /// canonicalization based on complexity guarantees the above ordering.
  105. ///
  106. /// This routine maps IR values to various complexity ranks:
  107. /// 0 -> undef
  108. /// 1 -> Constants
  109. /// 2 -> Other non-instructions
  110. /// 3 -> Arguments
  111. /// 4 -> Cast and (f)neg/not instructions
  112. /// 5 -> Other instructions
  113. static unsigned getComplexity(Value *V) {
  114. if (isa<Instruction>(V)) {
  115. if (isa<CastInst>(V) || match(V, m_Neg(PatternMatch::m_Value())) ||
  116. match(V, m_Not(PatternMatch::m_Value())) ||
  117. match(V, m_FNeg(PatternMatch::m_Value())))
  118. return 4;
  119. return 5;
  120. }
  121. if (isa<Argument>(V))
  122. return 3;
  123. return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
  124. }
  125. /// Predicate canonicalization reduces the number of patterns that need to be
  126. /// matched by other transforms. For example, we may swap the operands of a
  127. /// conditional branch or select to create a compare with a canonical
  128. /// (inverted) predicate which is then more likely to be matched with other
  129. /// values.
  130. static bool isCanonicalPredicate(CmpInst::Predicate Pred) {
  131. switch (Pred) {
  132. case CmpInst::ICMP_NE:
  133. case CmpInst::ICMP_ULE:
  134. case CmpInst::ICMP_SLE:
  135. case CmpInst::ICMP_UGE:
  136. case CmpInst::ICMP_SGE:
  137. // TODO: There are 16 FCMP predicates. Should others be (not) canonical?
  138. case CmpInst::FCMP_ONE:
  139. case CmpInst::FCMP_OLE:
  140. case CmpInst::FCMP_OGE:
  141. return false;
  142. default:
  143. return true;
  144. }
  145. }
  146. /// Given an exploded icmp instruction, return true if the comparison only
  147. /// checks the sign bit. If it only checks the sign bit, set TrueIfSigned if
  148. /// the result of the comparison is true when the input value is signed.
  149. static bool isSignBitCheck(ICmpInst::Predicate Pred, const APInt &RHS,
  150. bool &TrueIfSigned) {
  151. switch (Pred) {
  152. case ICmpInst::ICMP_SLT: // True if LHS s< 0
  153. TrueIfSigned = true;
  154. return RHS.isZero();
  155. case ICmpInst::ICMP_SLE: // True if LHS s<= -1
  156. TrueIfSigned = true;
  157. return RHS.isAllOnes();
  158. case ICmpInst::ICMP_SGT: // True if LHS s> -1
  159. TrueIfSigned = false;
  160. return RHS.isAllOnes();
  161. case ICmpInst::ICMP_SGE: // True if LHS s>= 0
  162. TrueIfSigned = false;
  163. return RHS.isZero();
  164. case ICmpInst::ICMP_UGT:
  165. // True if LHS u> RHS and RHS == sign-bit-mask - 1
  166. TrueIfSigned = true;
  167. return RHS.isMaxSignedValue();
  168. case ICmpInst::ICMP_UGE:
  169. // True if LHS u>= RHS and RHS == sign-bit-mask (2^7, 2^15, 2^31, etc)
  170. TrueIfSigned = true;
  171. return RHS.isMinSignedValue();
  172. case ICmpInst::ICMP_ULT:
  173. // True if LHS u< RHS and RHS == sign-bit-mask (2^7, 2^15, 2^31, etc)
  174. TrueIfSigned = false;
  175. return RHS.isMinSignedValue();
  176. case ICmpInst::ICMP_ULE:
  177. // True if LHS u<= RHS and RHS == sign-bit-mask - 1
  178. TrueIfSigned = false;
  179. return RHS.isMaxSignedValue();
  180. default:
  181. return false;
  182. }
  183. }
  184. /// Add one to a Constant
  185. static Constant *AddOne(Constant *C) {
  186. return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
  187. }
  188. /// Subtract one from a Constant
  189. static Constant *SubOne(Constant *C) {
  190. return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1));
  191. }
  192. std::optional<std::pair<
  193. CmpInst::Predicate,
  194. Constant *>> static getFlippedStrictnessPredicateAndConstant(CmpInst::
  195. Predicate
  196. Pred,
  197. Constant *C);
  198. static bool shouldAvoidAbsorbingNotIntoSelect(const SelectInst &SI) {
  199. // a ? b : false and a ? true : b are the canonical form of logical and/or.
  200. // This includes !a ? b : false and !a ? true : b. Absorbing the not into
  201. // the select by swapping operands would break recognition of this pattern
  202. // in other analyses, so don't do that.
  203. return match(&SI, PatternMatch::m_LogicalAnd(PatternMatch::m_Value(),
  204. PatternMatch::m_Value())) ||
  205. match(&SI, PatternMatch::m_LogicalOr(PatternMatch::m_Value(),
  206. PatternMatch::m_Value()));
  207. }
  208. /// Return true if the specified value is free to invert (apply ~ to).
  209. /// This happens in cases where the ~ can be eliminated. If WillInvertAllUses
  210. /// is true, work under the assumption that the caller intends to remove all
  211. /// uses of V and only keep uses of ~V.
  212. ///
  213. /// See also: canFreelyInvertAllUsersOf()
  214. static bool isFreeToInvert(Value *V, bool WillInvertAllUses) {
  215. // ~(~(X)) -> X.
  216. if (match(V, m_Not(PatternMatch::m_Value())))
  217. return true;
  218. // Constants can be considered to be not'ed values.
  219. if (match(V, PatternMatch::m_AnyIntegralConstant()))
  220. return true;
  221. // Compares can be inverted if all of their uses are being modified to use
  222. // the ~V.
  223. if (isa<CmpInst>(V))
  224. return WillInvertAllUses;
  225. // If `V` is of the form `A + Constant` then `-1 - V` can be folded into
  226. // `(-1 - Constant) - A` if we are willing to invert all of the uses.
  227. if (match(V, m_Add(PatternMatch::m_Value(), PatternMatch::m_ImmConstant())))
  228. return WillInvertAllUses;
  229. // If `V` is of the form `Constant - A` then `-1 - V` can be folded into
  230. // `A + (-1 - Constant)` if we are willing to invert all of the uses.
  231. if (match(V, m_Sub(PatternMatch::m_ImmConstant(), PatternMatch::m_Value())))
  232. return WillInvertAllUses;
  233. // Selects with invertible operands are freely invertible
  234. if (match(V,
  235. m_Select(PatternMatch::m_Value(), m_Not(PatternMatch::m_Value()),
  236. m_Not(PatternMatch::m_Value()))))
  237. return WillInvertAllUses;
  238. // Min/max may be in the form of intrinsics, so handle those identically
  239. // to select patterns.
  240. if (match(V, m_MaxOrMin(m_Not(PatternMatch::m_Value()),
  241. m_Not(PatternMatch::m_Value()))))
  242. return WillInvertAllUses;
  243. return false;
  244. }
  245. /// Given i1 V, can every user of V be freely adapted if V is changed to !V ?
  246. /// InstCombine's freelyInvertAllUsersOf() must be kept in sync with this fn.
  247. /// NOTE: for Instructions only!
  248. ///
  249. /// See also: isFreeToInvert()
  250. static bool canFreelyInvertAllUsersOf(Instruction *V, Value *IgnoredUser) {
  251. // Look at every user of V.
  252. for (Use &U : V->uses()) {
  253. if (U.getUser() == IgnoredUser)
  254. continue; // Don't consider this user.
  255. auto *I = cast<Instruction>(U.getUser());
  256. switch (I->getOpcode()) {
  257. case Instruction::Select:
  258. if (U.getOperandNo() != 0) // Only if the value is used as select cond.
  259. return false;
  260. if (shouldAvoidAbsorbingNotIntoSelect(*cast<SelectInst>(I)))
  261. return false;
  262. break;
  263. case Instruction::Br:
  264. assert(U.getOperandNo() == 0 && "Must be branching on that value.");
  265. break; // Free to invert by swapping true/false values/destinations.
  266. case Instruction::Xor: // Can invert 'xor' if it's a 'not', by ignoring
  267. // it.
  268. if (!match(I, m_Not(PatternMatch::m_Value())))
  269. return false; // Not a 'not'.
  270. break;
  271. default:
  272. return false; // Don't know, likely not freely invertible.
  273. }
  274. // So far all users were free to invert...
  275. }
  276. return true; // Can freely invert all users!
  277. }
  278. /// Some binary operators require special handling to avoid poison and
  279. /// undefined behavior. If a constant vector has undef elements, replace those
  280. /// undefs with identity constants if possible because those are always safe
  281. /// to execute. If no identity constant exists, replace undef with some other
  282. /// safe constant.
  283. static Constant *
  284. getSafeVectorConstantForBinop(BinaryOperator::BinaryOps Opcode, Constant *In,
  285. bool IsRHSConstant) {
  286. auto *InVTy = cast<FixedVectorType>(In->getType());
  287. Type *EltTy = InVTy->getElementType();
  288. auto *SafeC = ConstantExpr::getBinOpIdentity(Opcode, EltTy, IsRHSConstant);
  289. if (!SafeC) {
  290. // TODO: Should this be available as a constant utility function? It is
  291. // similar to getBinOpAbsorber().
  292. if (IsRHSConstant) {
  293. switch (Opcode) {
  294. case Instruction::SRem: // X % 1 = 0
  295. case Instruction::URem: // X %u 1 = 0
  296. SafeC = ConstantInt::get(EltTy, 1);
  297. break;
  298. case Instruction::FRem: // X % 1.0 (doesn't simplify, but it is safe)
  299. SafeC = ConstantFP::get(EltTy, 1.0);
  300. break;
  301. default:
  302. llvm_unreachable(
  303. "Only rem opcodes have no identity constant for RHS");
  304. }
  305. } else {
  306. switch (Opcode) {
  307. case Instruction::Shl: // 0 << X = 0
  308. case Instruction::LShr: // 0 >>u X = 0
  309. case Instruction::AShr: // 0 >> X = 0
  310. case Instruction::SDiv: // 0 / X = 0
  311. case Instruction::UDiv: // 0 /u X = 0
  312. case Instruction::SRem: // 0 % X = 0
  313. case Instruction::URem: // 0 %u X = 0
  314. case Instruction::Sub: // 0 - X (doesn't simplify, but it is safe)
  315. case Instruction::FSub: // 0.0 - X (doesn't simplify, but it is safe)
  316. case Instruction::FDiv: // 0.0 / X (doesn't simplify, but it is safe)
  317. case Instruction::FRem: // 0.0 % X = 0
  318. SafeC = Constant::getNullValue(EltTy);
  319. break;
  320. default:
  321. llvm_unreachable("Expected to find identity constant for opcode");
  322. }
  323. }
  324. }
  325. assert(SafeC && "Must have safe constant for binop");
  326. unsigned NumElts = InVTy->getNumElements();
  327. SmallVector<Constant *, 16> Out(NumElts);
  328. for (unsigned i = 0; i != NumElts; ++i) {
  329. Constant *C = In->getAggregateElement(i);
  330. Out[i] = isa<UndefValue>(C) ? SafeC : C;
  331. }
  332. return ConstantVector::get(Out);
  333. }
  334. void addToWorklist(Instruction *I) { Worklist.push(I); }
  335. AssumptionCache &getAssumptionCache() const { return AC; }
  336. TargetLibraryInfo &getTargetLibraryInfo() const { return TLI; }
  337. DominatorTree &getDominatorTree() const { return DT; }
  338. const DataLayout &getDataLayout() const { return DL; }
  339. const SimplifyQuery &getSimplifyQuery() const { return SQ; }
  340. OptimizationRemarkEmitter &getOptimizationRemarkEmitter() const {
  341. return ORE;
  342. }
  343. BlockFrequencyInfo *getBlockFrequencyInfo() const { return BFI; }
  344. ProfileSummaryInfo *getProfileSummaryInfo() const { return PSI; }
  345. LoopInfo *getLoopInfo() const { return LI; }
  346. // Call target specific combiners
  347. std::optional<Instruction *> targetInstCombineIntrinsic(IntrinsicInst &II);
  348. std::optional<Value *>
  349. targetSimplifyDemandedUseBitsIntrinsic(IntrinsicInst &II, APInt DemandedMask,
  350. KnownBits &Known,
  351. bool &KnownBitsComputed);
  352. std::optional<Value *> targetSimplifyDemandedVectorEltsIntrinsic(
  353. IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
  354. APInt &UndefElts2, APInt &UndefElts3,
  355. std::function<void(Instruction *, unsigned, APInt, APInt &)>
  356. SimplifyAndSetOp);
  357. /// Inserts an instruction \p New before instruction \p Old
  358. ///
  359. /// Also adds the new instruction to the worklist and returns \p New so that
  360. /// it is suitable for use as the return from the visitation patterns.
  361. Instruction *InsertNewInstBefore(Instruction *New, Instruction &Old) {
  362. assert(New && !New->getParent() &&
  363. "New instruction already inserted into a basic block!");
  364. BasicBlock *BB = Old.getParent();
  365. New->insertInto(BB, Old.getIterator()); // Insert inst
  366. Worklist.add(New);
  367. return New;
  368. }
  369. /// Same as InsertNewInstBefore, but also sets the debug loc.
  370. Instruction *InsertNewInstWith(Instruction *New, Instruction &Old) {
  371. New->setDebugLoc(Old.getDebugLoc());
  372. return InsertNewInstBefore(New, Old);
  373. }
  374. /// A combiner-aware RAUW-like routine.
  375. ///
  376. /// This method is to be used when an instruction is found to be dead,
  377. /// replaceable with another preexisting expression. Here we add all uses of
  378. /// I to the worklist, replace all uses of I with the new value, then return
  379. /// I, so that the inst combiner will know that I was modified.
  380. Instruction *replaceInstUsesWith(Instruction &I, Value *V) {
  381. // If there are no uses to replace, then we return nullptr to indicate that
  382. // no changes were made to the program.
  383. if (I.use_empty()) return nullptr;
  384. Worklist.pushUsersToWorkList(I); // Add all modified instrs to worklist.
  385. // If we are replacing the instruction with itself, this must be in a
  386. // segment of unreachable code, so just clobber the instruction.
  387. if (&I == V)
  388. V = PoisonValue::get(I.getType());
  389. LLVM_DEBUG(dbgs() << "IC: Replacing " << I << "\n"
  390. << " with " << *V << '\n');
  391. // If V is a new unnamed instruction, take the name from the old one.
  392. if (V->use_empty() && isa<Instruction>(V) && !V->hasName() && I.hasName())
  393. V->takeName(&I);
  394. I.replaceAllUsesWith(V);
  395. return &I;
  396. }
  397. /// Replace operand of instruction and add old operand to the worklist.
  398. Instruction *replaceOperand(Instruction &I, unsigned OpNum, Value *V) {
  399. Worklist.addValue(I.getOperand(OpNum));
  400. I.setOperand(OpNum, V);
  401. return &I;
  402. }
  403. /// Replace use and add the previously used value to the worklist.
  404. void replaceUse(Use &U, Value *NewValue) {
  405. Worklist.addValue(U);
  406. U = NewValue;
  407. }
  408. /// Combiner aware instruction erasure.
  409. ///
  410. /// When dealing with an instruction that has side effects or produces a void
  411. /// value, we can't rely on DCE to delete the instruction. Instead, visit
  412. /// methods should return the value returned by this function.
  413. virtual Instruction *eraseInstFromFunction(Instruction &I) = 0;
  414. void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth,
  415. const Instruction *CxtI) const {
  416. llvm::computeKnownBits(V, Known, DL, Depth, &AC, CxtI, &DT);
  417. }
  418. KnownBits computeKnownBits(const Value *V, unsigned Depth,
  419. const Instruction *CxtI) const {
  420. return llvm::computeKnownBits(V, DL, Depth, &AC, CxtI, &DT);
  421. }
  422. bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero = false,
  423. unsigned Depth = 0,
  424. const Instruction *CxtI = nullptr) {
  425. return llvm::isKnownToBeAPowerOfTwo(V, DL, OrZero, Depth, &AC, CxtI, &DT);
  426. }
  427. bool MaskedValueIsZero(const Value *V, const APInt &Mask, unsigned Depth = 0,
  428. const Instruction *CxtI = nullptr) const {
  429. return llvm::MaskedValueIsZero(V, Mask, DL, Depth, &AC, CxtI, &DT);
  430. }
  431. unsigned ComputeNumSignBits(const Value *Op, unsigned Depth = 0,
  432. const Instruction *CxtI = nullptr) const {
  433. return llvm::ComputeNumSignBits(Op, DL, Depth, &AC, CxtI, &DT);
  434. }
  435. unsigned ComputeMaxSignificantBits(const Value *Op, unsigned Depth = 0,
  436. const Instruction *CxtI = nullptr) const {
  437. return llvm::ComputeMaxSignificantBits(Op, DL, Depth, &AC, CxtI, &DT);
  438. }
  439. OverflowResult computeOverflowForUnsignedMul(const Value *LHS,
  440. const Value *RHS,
  441. const Instruction *CxtI) const {
  442. return llvm::computeOverflowForUnsignedMul(LHS, RHS, DL, &AC, CxtI, &DT);
  443. }
  444. OverflowResult computeOverflowForSignedMul(const Value *LHS, const Value *RHS,
  445. const Instruction *CxtI) const {
  446. return llvm::computeOverflowForSignedMul(LHS, RHS, DL, &AC, CxtI, &DT);
  447. }
  448. OverflowResult computeOverflowForUnsignedAdd(const Value *LHS,
  449. const Value *RHS,
  450. const Instruction *CxtI) const {
  451. return llvm::computeOverflowForUnsignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
  452. }
  453. OverflowResult computeOverflowForSignedAdd(const Value *LHS, const Value *RHS,
  454. const Instruction *CxtI) const {
  455. return llvm::computeOverflowForSignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
  456. }
  457. OverflowResult computeOverflowForUnsignedSub(const Value *LHS,
  458. const Value *RHS,
  459. const Instruction *CxtI) const {
  460. return llvm::computeOverflowForUnsignedSub(LHS, RHS, DL, &AC, CxtI, &DT);
  461. }
  462. OverflowResult computeOverflowForSignedSub(const Value *LHS, const Value *RHS,
  463. const Instruction *CxtI) const {
  464. return llvm::computeOverflowForSignedSub(LHS, RHS, DL, &AC, CxtI, &DT);
  465. }
  466. virtual bool SimplifyDemandedBits(Instruction *I, unsigned OpNo,
  467. const APInt &DemandedMask, KnownBits &Known,
  468. unsigned Depth = 0) = 0;
  469. virtual Value *
  470. SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, APInt &UndefElts,
  471. unsigned Depth = 0,
  472. bool AllowMultipleUsers = false) = 0;
  473. };
  474. } // namespace llvm
  475. #undef DEBUG_TYPE
  476. #endif
  477. #ifdef __GNUC__
  478. #pragma GCC diagnostic pop
  479. #endif