LLVM 19.0.0git
InstCombineInternal.h
Go to the documentation of this file.
1//===- InstCombineInternal.h - InstCombine pass internals -------*- 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/// \file
10///
11/// This file provides internal interfaces used to implement the InstCombine.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
16#define LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
17
18#include "llvm/ADT/Statistic.h"
23#include "llvm/IR/IRBuilder.h"
24#include "llvm/IR/InstVisitor.h"
26#include "llvm/IR/Value.h"
27#include "llvm/Support/Debug.h"
31#include <cassert>
32
33#define DEBUG_TYPE "instcombine"
35
36using namespace llvm::PatternMatch;
37
38// As a default, let's assume that we want to be aggressive,
39// and attempt to traverse with no limits in attempt to sink negation.
40static constexpr unsigned NegatorDefaultMaxDepth = ~0U;
41
42// Let's guesstimate that most often we will end up visiting/producing
43// fairly small number of new instructions.
44static constexpr unsigned NegatorMaxNodesSSO = 16;
45
46namespace llvm {
47
48class AAResults;
49class APInt;
50class AssumptionCache;
52class DataLayout;
53class DominatorTree;
54class GEPOperator;
55class GlobalVariable;
56class LoopInfo;
60class User;
61
63 : public InstCombiner,
64 public InstVisitor<InstCombinerImpl, Instruction *> {
65public:
67 bool MinimizeSize, AAResults *AA, AssumptionCache &AC,
71 ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI)
72 : InstCombiner(Worklist, Builder, MinimizeSize, AA, AC, TLI, TTI, DT, ORE,
73 BFI, BPI, PSI, DL, LI) {}
74
75 virtual ~InstCombinerImpl() = default;
76
77 /// Perform early cleanup and prepare the InstCombine worklist.
78 bool prepareWorklist(Function &F,
80
81 /// Run the combiner over the entire worklist until it is empty.
82 ///
83 /// \returns true if the IR is changed.
84 bool run();
85
86 // Visitation implementation - Implement instruction combining for different
87 // instruction types. The semantics are as follows:
88 // Return Value:
89 // null - No change was made
90 // I - Change was made, I is still valid, I may be dead though
91 // otherwise - Change was made, replace I with returned instruction
92 //
93 Instruction *visitFNeg(UnaryOperator &I);
94 Instruction *visitAdd(BinaryOperator &I);
95 Instruction *visitFAdd(BinaryOperator &I);
96 Value *OptimizePointerDifference(
97 Value *LHS, Value *RHS, Type *Ty, bool isNUW);
98 Instruction *visitSub(BinaryOperator &I);
99 Instruction *visitFSub(BinaryOperator &I);
100 Instruction *visitMul(BinaryOperator &I);
101 Instruction *foldPowiReassoc(BinaryOperator &I);
102 Instruction *foldFMulReassoc(BinaryOperator &I);
103 Instruction *visitFMul(BinaryOperator &I);
104 Instruction *visitURem(BinaryOperator &I);
105 Instruction *visitSRem(BinaryOperator &I);
106 Instruction *visitFRem(BinaryOperator &I);
107 bool simplifyDivRemOfSelectWithZeroOp(BinaryOperator &I);
108 Instruction *commonIRemTransforms(BinaryOperator &I);
109 Instruction *commonIDivTransforms(BinaryOperator &I);
110 Instruction *visitUDiv(BinaryOperator &I);
111 Instruction *visitSDiv(BinaryOperator &I);
112 Instruction *visitFDiv(BinaryOperator &I);
113 Value *simplifyRangeCheck(ICmpInst *Cmp0, ICmpInst *Cmp1, bool Inverted);
114 Instruction *visitAnd(BinaryOperator &I);
115 Instruction *visitOr(BinaryOperator &I);
116 bool sinkNotIntoLogicalOp(Instruction &I);
117 bool sinkNotIntoOtherHandOfLogicalOp(Instruction &I);
118 Instruction *visitXor(BinaryOperator &I);
119 Instruction *visitShl(BinaryOperator &I);
120 Value *reassociateShiftAmtsOfTwoSameDirectionShifts(
121 BinaryOperator *Sh0, const SimplifyQuery &SQ,
122 bool AnalyzeForSignBitExtraction = false);
123 Instruction *canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(
125 Instruction *foldVariableSignZeroExtensionOfVariableHighBitExtract(
126 BinaryOperator &OldAShr);
127 Instruction *visitAShr(BinaryOperator &I);
128 Instruction *visitLShr(BinaryOperator &I);
129 Instruction *commonShiftTransforms(BinaryOperator &I);
130 Instruction *visitFCmpInst(FCmpInst &I);
131 CmpInst *canonicalizeICmpPredicate(CmpInst &I);
132 Instruction *visitICmpInst(ICmpInst &I);
133 Instruction *FoldShiftByConstant(Value *Op0, Constant *Op1,
135 Instruction *commonCastTransforms(CastInst &CI);
136 Instruction *visitTrunc(TruncInst &CI);
137 Instruction *visitZExt(ZExtInst &Zext);
138 Instruction *visitSExt(SExtInst &Sext);
139 Instruction *visitFPTrunc(FPTruncInst &CI);
140 Instruction *visitFPExt(CastInst &CI);
141 Instruction *visitFPToUI(FPToUIInst &FI);
142 Instruction *visitFPToSI(FPToSIInst &FI);
143 Instruction *visitUIToFP(CastInst &CI);
144 Instruction *visitSIToFP(CastInst &CI);
145 Instruction *visitPtrToInt(PtrToIntInst &CI);
146 Instruction *visitIntToPtr(IntToPtrInst &CI);
147 Instruction *visitBitCast(BitCastInst &CI);
148 Instruction *visitAddrSpaceCast(AddrSpaceCastInst &CI);
149 Instruction *foldItoFPtoI(CastInst &FI);
151 Instruction *visitCallInst(CallInst &CI);
152 Instruction *visitInvokeInst(InvokeInst &II);
153 Instruction *visitCallBrInst(CallBrInst &CBI);
154
155 Instruction *SliceUpIllegalIntegerPHI(PHINode &PN);
156 Instruction *visitPHINode(PHINode &PN);
157 Instruction *visitGetElementPtrInst(GetElementPtrInst &GEP);
158 Instruction *visitGEPOfGEP(GetElementPtrInst &GEP, GEPOperator *Src);
159 Instruction *visitAllocaInst(AllocaInst &AI);
160 Instruction *visitAllocSite(Instruction &FI);
161 Instruction *visitFree(CallInst &FI, Value *FreedOp);
162 Instruction *visitLoadInst(LoadInst &LI);
163 Instruction *visitStoreInst(StoreInst &SI);
164 Instruction *visitAtomicRMWInst(AtomicRMWInst &SI);
165 Instruction *visitUnconditionalBranchInst(BranchInst &BI);
166 Instruction *visitBranchInst(BranchInst &BI);
167 Instruction *visitFenceInst(FenceInst &FI);
168 Instruction *visitSwitchInst(SwitchInst &SI);
169 Instruction *visitReturnInst(ReturnInst &RI);
170 Instruction *visitUnreachableInst(UnreachableInst &I);
172 foldAggregateConstructionIntoAggregateReuse(InsertValueInst &OrigIVI);
173 Instruction *visitInsertValueInst(InsertValueInst &IV);
174 Instruction *visitInsertElementInst(InsertElementInst &IE);
175 Instruction *visitExtractElementInst(ExtractElementInst &EI);
176 Instruction *simplifyBinOpSplats(ShuffleVectorInst &SVI);
177 Instruction *visitShuffleVectorInst(ShuffleVectorInst &SVI);
178 Instruction *visitExtractValueInst(ExtractValueInst &EV);
179 Instruction *visitLandingPadInst(LandingPadInst &LI);
180 Instruction *visitVAEndInst(VAEndInst &I);
181 Value *pushFreezeToPreventPoisonFromPropagating(FreezeInst &FI);
182 bool freezeOtherUses(FreezeInst &FI);
183 Instruction *foldFreezeIntoRecurrence(FreezeInst &I, PHINode *PN);
184 Instruction *visitFreeze(FreezeInst &I);
185
186 /// Specify what to return for unhandled instructions.
188
189 /// True when DB dominates all uses of DI except UI.
190 /// UI must be in the same block as DI.
191 /// The routine checks that the DI parent and DB are different.
192 bool dominatesAllUses(const Instruction *DI, const Instruction *UI,
193 const BasicBlock *DB) const;
194
195 /// Try to replace select with select operand SIOpd in SI-ICmp sequence.
196 bool replacedSelectWithOperand(SelectInst *SI, const ICmpInst *Icmp,
197 const unsigned SIOpd);
198
199 LoadInst *combineLoadToNewType(LoadInst &LI, Type *NewTy,
200 const Twine &Suffix = "");
201
203 FPClassTest Interested = fcAllFlags,
204 const Instruction *CtxI = nullptr,
205 unsigned Depth = 0) const {
207 Val, FMF, Interested, Depth,
208 getSimplifyQuery().getWithInstruction(CtxI));
209 }
210
212 FPClassTest Interested = fcAllFlags,
213 const Instruction *CtxI = nullptr,
214 unsigned Depth = 0) const {
216 Val, Interested, Depth, getSimplifyQuery().getWithInstruction(CtxI));
217 }
218
219 /// Check if fmul \p MulVal, +0.0 will yield +0.0 (or signed zero is
220 /// ignorable).
222 const Instruction *CtxI) const;
223
224 Constant *getLosslessTrunc(Constant *C, Type *TruncTy, unsigned ExtOp) {
225 Constant *TruncC = ConstantExpr::getTrunc(C, TruncTy);
226 Constant *ExtTruncC =
227 ConstantFoldCastOperand(ExtOp, TruncC, C->getType(), DL);
228 if (ExtTruncC && ExtTruncC == C)
229 return TruncC;
230 return nullptr;
231 }
232
234 return getLosslessTrunc(C, TruncTy, Instruction::ZExt);
235 }
236
238 return getLosslessTrunc(C, TruncTy, Instruction::SExt);
239 }
240
241 std::optional<std::pair<Intrinsic::ID, SmallVector<Value *, 3>>>
242 convertOrOfShiftsToFunnelShift(Instruction &Or);
243
244private:
245 bool annotateAnyAllocSite(CallBase &Call, const TargetLibraryInfo *TLI);
246 bool isDesirableIntType(unsigned BitWidth) const;
247 bool shouldChangeType(unsigned FromBitWidth, unsigned ToBitWidth) const;
248 bool shouldChangeType(Type *From, Type *To) const;
249 Value *dyn_castNegVal(Value *V) const;
250
251 /// Classify whether a cast is worth optimizing.
252 ///
253 /// This is a helper to decide whether the simplification of
254 /// logic(cast(A), cast(B)) to cast(logic(A, B)) should be performed.
255 ///
256 /// \param CI The cast we are interested in.
257 ///
258 /// \return true if this cast actually results in any code being generated and
259 /// if it cannot already be eliminated by some other transformation.
260 bool shouldOptimizeCast(CastInst *CI);
261
262 /// Try to optimize a sequence of instructions checking if an operation
263 /// on LHS and RHS overflows.
264 ///
265 /// If this overflow check is done via one of the overflow check intrinsics,
266 /// then CtxI has to be the call instruction calling that intrinsic. If this
267 /// overflow check is done by arithmetic followed by a compare, then CtxI has
268 /// to be the arithmetic instruction.
269 ///
270 /// If a simplification is possible, stores the simplified result of the
271 /// operation in OperationResult and result of the overflow check in
272 /// OverflowResult, and return true. If no simplification is possible,
273 /// returns false.
274 bool OptimizeOverflowCheck(Instruction::BinaryOps BinaryOp, bool IsSigned,
275 Value *LHS, Value *RHS,
276 Instruction &CtxI, Value *&OperationResult,
278
279 Instruction *visitCallBase(CallBase &Call);
280 Instruction *tryOptimizeCall(CallInst *CI);
281 bool transformConstExprCastCall(CallBase &Call);
282 Instruction *transformCallThroughTrampoline(CallBase &Call,
283 IntrinsicInst &Tramp);
284
285 // Return (a, b) if (LHS, RHS) is known to be (a, b) or (b, a).
286 // Otherwise, return std::nullopt
287 // Currently it matches:
288 // - LHS = (select c, a, b), RHS = (select c, b, a)
289 // - LHS = (phi [a, BB0], [b, BB1]), RHS = (phi [b, BB0], [a, BB1])
290 // - LHS = min(a, b), RHS = max(a, b)
291 std::optional<std::pair<Value *, Value *>> matchSymmetricPair(Value *LHS,
292 Value *RHS);
293
294 Value *simplifyMaskedLoad(IntrinsicInst &II);
295 Instruction *simplifyMaskedStore(IntrinsicInst &II);
296 Instruction *simplifyMaskedGather(IntrinsicInst &II);
297 Instruction *simplifyMaskedScatter(IntrinsicInst &II);
298
299 /// Transform (zext icmp) to bitwise / integer operations in order to
300 /// eliminate it.
301 ///
302 /// \param ICI The icmp of the (zext icmp) pair we are interested in.
303 /// \parem CI The zext of the (zext icmp) pair we are interested in.
304 ///
305 /// \return null if the transformation cannot be performed. If the
306 /// transformation can be performed the new instruction that replaces the
307 /// (zext icmp) pair will be returned.
308 Instruction *transformZExtICmp(ICmpInst *Cmp, ZExtInst &Zext);
309
310 Instruction *transformSExtICmp(ICmpInst *Cmp, SExtInst &Sext);
311
312 bool willNotOverflowSignedAdd(const WithCache<const Value *> &LHS,
314 const Instruction &CxtI) const {
315 return computeOverflowForSignedAdd(LHS, RHS, &CxtI) ==
316 OverflowResult::NeverOverflows;
317 }
318
319 bool willNotOverflowUnsignedAdd(const WithCache<const Value *> &LHS,
321 const Instruction &CxtI) const {
322 return computeOverflowForUnsignedAdd(LHS, RHS, &CxtI) ==
323 OverflowResult::NeverOverflows;
324 }
325
326 bool willNotOverflowAdd(const Value *LHS, const Value *RHS,
327 const Instruction &CxtI, bool IsSigned) const {
328 return IsSigned ? willNotOverflowSignedAdd(LHS, RHS, CxtI)
329 : willNotOverflowUnsignedAdd(LHS, RHS, CxtI);
330 }
331
332 bool willNotOverflowSignedSub(const Value *LHS, const Value *RHS,
333 const Instruction &CxtI) const {
334 return computeOverflowForSignedSub(LHS, RHS, &CxtI) ==
335 OverflowResult::NeverOverflows;
336 }
337
338 bool willNotOverflowUnsignedSub(const Value *LHS, const Value *RHS,
339 const Instruction &CxtI) const {
340 return computeOverflowForUnsignedSub(LHS, RHS, &CxtI) ==
341 OverflowResult::NeverOverflows;
342 }
343
344 bool willNotOverflowSub(const Value *LHS, const Value *RHS,
345 const Instruction &CxtI, bool IsSigned) const {
346 return IsSigned ? willNotOverflowSignedSub(LHS, RHS, CxtI)
347 : willNotOverflowUnsignedSub(LHS, RHS, CxtI);
348 }
349
350 bool willNotOverflowSignedMul(const Value *LHS, const Value *RHS,
351 const Instruction &CxtI) const {
352 return computeOverflowForSignedMul(LHS, RHS, &CxtI) ==
353 OverflowResult::NeverOverflows;
354 }
355
356 bool willNotOverflowUnsignedMul(const Value *LHS, const Value *RHS,
357 const Instruction &CxtI,
358 bool IsNSW = false) const {
359 return computeOverflowForUnsignedMul(LHS, RHS, &CxtI, IsNSW) ==
360 OverflowResult::NeverOverflows;
361 }
362
363 bool willNotOverflowMul(const Value *LHS, const Value *RHS,
364 const Instruction &CxtI, bool IsSigned) const {
365 return IsSigned ? willNotOverflowSignedMul(LHS, RHS, CxtI)
366 : willNotOverflowUnsignedMul(LHS, RHS, CxtI);
367 }
368
370 const Value *RHS, const Instruction &CxtI,
371 bool IsSigned) const {
372 switch (Opcode) {
373 case Instruction::Add: return willNotOverflowAdd(LHS, RHS, CxtI, IsSigned);
374 case Instruction::Sub: return willNotOverflowSub(LHS, RHS, CxtI, IsSigned);
375 case Instruction::Mul: return willNotOverflowMul(LHS, RHS, CxtI, IsSigned);
376 default: llvm_unreachable("Unexpected opcode for overflow query");
377 }
378 }
379
380 Value *EmitGEPOffset(GEPOperator *GEP, bool RewriteGEP = false);
381 Instruction *scalarizePHI(ExtractElementInst &EI, PHINode *PN);
382 Instruction *foldBitcastExtElt(ExtractElementInst &ExtElt);
383 Instruction *foldCastedBitwiseLogic(BinaryOperator &I);
384 Instruction *foldFBinOpOfIntCasts(BinaryOperator &I);
385 // Should only be called by `foldFBinOpOfIntCasts`.
386 Instruction *foldFBinOpOfIntCastsFromSign(
387 BinaryOperator &BO, bool OpsFromSigned, std::array<Value *, 2> IntOps,
389 Instruction *foldBinopOfSextBoolToSelect(BinaryOperator &I);
390 Instruction *narrowBinOp(TruncInst &Trunc);
391 Instruction *narrowMaskedBinOp(BinaryOperator &And);
392 Instruction *narrowMathIfNoOverflow(BinaryOperator &I);
393 Instruction *narrowFunnelShift(TruncInst &Trunc);
394 Instruction *optimizeBitCastFromPhi(CastInst &CI, PHINode *PN);
395 Instruction *matchSAddSubSat(IntrinsicInst &MinMax1);
396 Instruction *foldNot(BinaryOperator &I);
397 Instruction *foldBinOpOfDisplacedShifts(BinaryOperator &I);
398
399 /// Determine if a pair of casts can be replaced by a single cast.
400 ///
401 /// \param CI1 The first of a pair of casts.
402 /// \param CI2 The second of a pair of casts.
403 ///
404 /// \return 0 if the cast pair cannot be eliminated, otherwise returns an
405 /// Instruction::CastOps value for a cast that can replace the pair, casting
406 /// CI1->getSrcTy() to CI2->getDstTy().
407 ///
408 /// \see CastInst::isEliminableCastPair
409 Instruction::CastOps isEliminableCastPair(const CastInst *CI1,
410 const CastInst *CI2);
411 Value *simplifyIntToPtrRoundTripCast(Value *Val);
412
413 Value *foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS, Instruction &I,
414 bool IsAnd, bool IsLogical = false);
415 Value *foldXorOfICmps(ICmpInst *LHS, ICmpInst *RHS, BinaryOperator &Xor);
416
417 Value *foldEqOfParts(ICmpInst *Cmp0, ICmpInst *Cmp1, bool IsAnd);
418
419 Value *foldAndOrOfICmpsUsingRanges(ICmpInst *ICmp1, ICmpInst *ICmp2,
420 bool IsAnd);
421
422 /// Optimize (fcmp)&(fcmp) or (fcmp)|(fcmp).
423 /// NOTE: Unlike most of instcombine, this returns a Value which should
424 /// already be inserted into the function.
425 Value *foldLogicOfFCmps(FCmpInst *LHS, FCmpInst *RHS, bool IsAnd,
426 bool IsLogicalSelect = false);
427
428 Instruction *foldLogicOfIsFPClass(BinaryOperator &Operator, Value *LHS,
429 Value *RHS);
430
432 canonicalizeConditionalNegationViaMathToSelect(BinaryOperator &i);
433
434 Value *foldAndOrOfICmpsOfAndWithPow2(ICmpInst *LHS, ICmpInst *RHS,
435 Instruction *CxtI, bool IsAnd,
436 bool IsLogical = false);
437 Value *matchSelectFromAndOr(Value *A, Value *B, Value *C, Value *D,
438 bool InvertFalseVal = false);
439 Value *getSelectCondition(Value *A, Value *B, bool ABIsTheSame);
440
441 Instruction *foldLShrOverflowBit(BinaryOperator &I);
442 Instruction *foldExtractOfOverflowIntrinsic(ExtractValueInst &EV);
443 Instruction *foldIntrinsicWithOverflowCommon(IntrinsicInst *II);
444 Instruction *foldIntrinsicIsFPClass(IntrinsicInst &II);
445 Instruction *foldFPSignBitOps(BinaryOperator &I);
446 Instruction *foldFDivConstantDivisor(BinaryOperator &I);
447
448 // Optimize one of these forms:
449 // and i1 Op, SI / select i1 Op, i1 SI, i1 false (if IsAnd = true)
450 // or i1 Op, SI / select i1 Op, i1 true, i1 SI (if IsAnd = false)
451 // into simplier select instruction using isImpliedCondition.
452 Instruction *foldAndOrOfSelectUsingImpliedCond(Value *Op, SelectInst &SI,
453 bool IsAnd);
454
455 Instruction *hoistFNegAboveFMulFDiv(Value *FNegOp, Instruction &FMFSource);
456
457public:
458 /// Create and insert the idiom we use to indicate a block is unreachable
459 /// without having to rewrite the CFG from within InstCombine.
461 auto &Ctx = InsertAt->getContext();
462 auto *SI = new StoreInst(ConstantInt::getTrue(Ctx),
463 PoisonValue::get(PointerType::getUnqual(Ctx)),
464 /*isVolatile*/ false, Align(1));
465 InsertNewInstBefore(SI, InsertAt->getIterator());
466 }
467
468 /// Combiner aware instruction erasure.
469 ///
470 /// When dealing with an instruction that has side effects or produces a void
471 /// value, we can't rely on DCE to delete the instruction. Instead, visit
472 /// methods should return the value returned by this function.
474 LLVM_DEBUG(dbgs() << "IC: ERASE " << I << '\n');
475 assert(I.use_empty() && "Cannot erase instruction that is used!");
477
478 // Make sure that we reprocess all operands now that we reduced their
479 // use counts.
480 SmallVector<Value *> Ops(I.operands());
481 Worklist.remove(&I);
482 DC.removeValue(&I);
483 I.eraseFromParent();
484 for (Value *Op : Ops)
485 Worklist.handleUseCountDecrement(Op);
486 MadeIRChange = true;
487 return nullptr; // Don't do anything with FI
488 }
489
490 OverflowResult computeOverflow(
491 Instruction::BinaryOps BinaryOp, bool IsSigned,
492 Value *LHS, Value *RHS, Instruction *CxtI) const;
493
494 /// Performs a few simplifications for operators which are associative
495 /// or commutative.
496 bool SimplifyAssociativeOrCommutative(BinaryOperator &I);
497
498 /// Tries to simplify binary operations which some other binary
499 /// operation distributes over.
500 ///
501 /// It does this by either by factorizing out common terms (eg "(A*B)+(A*C)"
502 /// -> "A*(B+C)") or expanding out if this results in simplifications (eg: "A
503 /// & (B | C) -> (A&B) | (A&C)" if this is a win). Returns the simplified
504 /// value, or null if it didn't simplify.
505 Value *foldUsingDistributiveLaws(BinaryOperator &I);
506
507 /// Tries to simplify add operations using the definition of remainder.
508 ///
509 /// The definition of remainder is X % C = X - (X / C ) * C. The add
510 /// expression X % C0 + (( X / C0 ) % C1) * C0 can be simplified to
511 /// X % (C0 * C1)
512 Value *SimplifyAddWithRemainder(BinaryOperator &I);
513
514 // Binary Op helper for select operations where the expression can be
515 // efficiently reorganized.
516 Value *SimplifySelectsFeedingBinaryOp(BinaryOperator &I, Value *LHS,
517 Value *RHS);
518
519 // If `I` has operand `(ctpop (not x))`, fold `I` with `(sub nuw nsw
520 // BitWidth(x), (ctpop x))`.
521 Instruction *tryFoldInstWithCtpopWithNot(Instruction *I);
522
523 // (Binop1 (Binop2 (logic_shift X, C), C1), (logic_shift Y, C))
524 // -> (logic_shift (Binop1 (Binop2 X, inv_logic_shift(C1, C)), Y), C)
525 // (Binop1 (Binop2 (logic_shift X, Amt), Mask), (logic_shift Y, Amt))
526 // -> (BinOp (logic_shift (BinOp X, Y)), Mask)
527 Instruction *foldBinOpShiftWithShift(BinaryOperator &I);
528
529 /// Tries to simplify binops of select and cast of the select condition.
530 ///
531 /// (Binop (cast C), (select C, T, F))
532 /// -> (select C, C0, C1)
533 Instruction *foldBinOpOfSelectAndCastOfSelectCondition(BinaryOperator &I);
534
535 /// This tries to simplify binary operations by factorizing out common terms
536 /// (e. g. "(A*B)+(A*C)" -> "A*(B+C)").
537 Value *tryFactorizationFolds(BinaryOperator &I);
538
539 /// Match a select chain which produces one of three values based on whether
540 /// the LHS is less than, equal to, or greater than RHS respectively.
541 /// Return true if we matched a three way compare idiom. The LHS, RHS, Less,
542 /// Equal and Greater values are saved in the matching process and returned to
543 /// the caller.
544 bool matchThreeWayIntCompare(SelectInst *SI, Value *&LHS, Value *&RHS,
545 ConstantInt *&Less, ConstantInt *&Equal,
546 ConstantInt *&Greater);
547
548 /// Attempts to replace V with a simpler value based on the demanded
549 /// bits.
550 Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, KnownBits &Known,
551 unsigned Depth, Instruction *CxtI);
552 bool SimplifyDemandedBits(Instruction *I, unsigned Op,
553 const APInt &DemandedMask, KnownBits &Known,
554 unsigned Depth = 0) override;
555
556 /// Helper routine of SimplifyDemandedUseBits. It computes KnownZero/KnownOne
557 /// bits. It also tries to handle simplifications that can be done based on
558 /// DemandedMask, but without modifying the Instruction.
559 Value *SimplifyMultipleUseDemandedBits(Instruction *I,
560 const APInt &DemandedMask,
561 KnownBits &Known,
562 unsigned Depth, Instruction *CxtI);
563
564 /// Helper routine of SimplifyDemandedUseBits. It tries to simplify demanded
565 /// bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.
566 Value *simplifyShrShlDemandedBits(
567 Instruction *Shr, const APInt &ShrOp1, Instruction *Shl,
568 const APInt &ShlOp1, const APInt &DemandedMask, KnownBits &Known);
569
570 /// Tries to simplify operands to an integer instruction based on its
571 /// demanded bits.
572 bool SimplifyDemandedInstructionBits(Instruction &Inst);
573 bool SimplifyDemandedInstructionBits(Instruction &Inst, KnownBits &Known);
574
575 Value *SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
576 APInt &PoisonElts, unsigned Depth = 0,
577 bool AllowMultipleUsers = false) override;
578
579 /// Attempts to replace V with a simpler value based on the demanded
580 /// floating-point classes
581 Value *SimplifyDemandedUseFPClass(Value *V, FPClassTest DemandedMask,
582 KnownFPClass &Known, unsigned Depth,
583 Instruction *CxtI);
584 bool SimplifyDemandedFPClass(Instruction *I, unsigned Op,
585 FPClassTest DemandedMask, KnownFPClass &Known,
586 unsigned Depth = 0);
587
588 /// Canonicalize the position of binops relative to shufflevector.
589 Instruction *foldVectorBinop(BinaryOperator &Inst);
591 Instruction *foldSelectShuffle(ShuffleVectorInst &Shuf);
592
593 /// Given a binary operator, cast instruction, or select which has a PHI node
594 /// as operand #0, see if we can fold the instruction into the PHI (which is
595 /// only possible if all operands to the PHI are constants).
596 Instruction *foldOpIntoPhi(Instruction &I, PHINode *PN);
597
598 /// For a binary operator with 2 phi operands, try to hoist the binary
599 /// operation before the phi. This can result in fewer instructions in
600 /// patterns where at least one set of phi operands simplifies.
601 /// Example:
602 /// BB3: binop (phi [X, BB1], [C1, BB2]), (phi [Y, BB1], [C2, BB2])
603 /// -->
604 /// BB1: BO = binop X, Y
605 /// BB3: phi [BO, BB1], [(binop C1, C2), BB2]
606 Instruction *foldBinopWithPhiOperands(BinaryOperator &BO);
607
608 /// Given an instruction with a select as one operand and a constant as the
609 /// other operand, try to fold the binary operator into the select arguments.
610 /// This also works for Cast instructions, which obviously do not have a
611 /// second operand.
612 Instruction *FoldOpIntoSelect(Instruction &Op, SelectInst *SI,
613 bool FoldWithMultiUse = false);
614
615 /// This is a convenience wrapper function for the above two functions.
616 Instruction *foldBinOpIntoSelectOrPhi(BinaryOperator &I);
617
618 Instruction *foldAddWithConstant(BinaryOperator &Add);
619
620 Instruction *foldSquareSumInt(BinaryOperator &I);
621 Instruction *foldSquareSumFP(BinaryOperator &I);
622
623 /// Try to rotate an operation below a PHI node, using PHI nodes for
624 /// its operands.
625 Instruction *foldPHIArgOpIntoPHI(PHINode &PN);
626 Instruction *foldPHIArgBinOpIntoPHI(PHINode &PN);
627 Instruction *foldPHIArgInsertValueInstructionIntoPHI(PHINode &PN);
628 Instruction *foldPHIArgExtractValueInstructionIntoPHI(PHINode &PN);
629 Instruction *foldPHIArgGEPIntoPHI(PHINode &PN);
630 Instruction *foldPHIArgLoadIntoPHI(PHINode &PN);
631 Instruction *foldPHIArgZextsIntoPHI(PHINode &PN);
632 Instruction *foldPHIArgIntToPtrToPHI(PHINode &PN);
633
634 /// If an integer typed PHI has only one use which is an IntToPtr operation,
635 /// replace the PHI with an existing pointer typed PHI if it exists. Otherwise
636 /// insert a new pointer typed PHI and replace the original one.
637 bool foldIntegerTypedPHI(PHINode &PN);
638
639 /// Helper function for FoldPHIArgXIntoPHI() to set debug location for the
640 /// folded operation.
641 void PHIArgMergedDebugLoc(Instruction *Inst, PHINode &PN);
642
643 Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
645 Instruction *foldSelectICmp(ICmpInst::Predicate Pred, SelectInst *SI,
646 Value *RHS, const ICmpInst &I);
647 bool foldAllocaCmp(AllocaInst *Alloca);
648 Instruction *foldCmpLoadFromIndexedGlobal(LoadInst *LI,
650 GlobalVariable *GV, CmpInst &ICI,
651 ConstantInt *AndCst = nullptr);
652 Instruction *foldFCmpIntToFPConst(FCmpInst &I, Instruction *LHSI,
653 Constant *RHSC);
654 Instruction *foldICmpAddOpConst(Value *X, const APInt &C,
656 Instruction *foldICmpWithCastOp(ICmpInst &ICmp);
657 Instruction *foldICmpWithZextOrSext(ICmpInst &ICmp);
658
659 Instruction *foldICmpUsingKnownBits(ICmpInst &Cmp);
661 Instruction *foldICmpWithConstant(ICmpInst &Cmp);
662 Instruction *foldICmpUsingBoolRange(ICmpInst &I);
663 Instruction *foldICmpInstWithConstant(ICmpInst &Cmp);
664 Instruction *foldICmpInstWithConstantNotInt(ICmpInst &Cmp);
665 Instruction *foldICmpInstWithConstantAllowPoison(ICmpInst &Cmp,
666 const APInt &C);
667 Instruction *foldICmpBinOp(ICmpInst &Cmp, const SimplifyQuery &SQ);
668 Instruction *foldICmpWithMinMax(Instruction &I, MinMaxIntrinsic *MinMax,
669 Value *Z, ICmpInst::Predicate Pred);
670 Instruction *foldICmpEquality(ICmpInst &Cmp);
671 Instruction *foldIRemByPowerOfTwoToBitTest(ICmpInst &I);
672 Instruction *foldSignBitTest(ICmpInst &I);
673 Instruction *foldICmpWithZero(ICmpInst &Cmp);
674
675 Value *foldMultiplicationOverflowCheck(ICmpInst &Cmp);
676
677 Instruction *foldICmpBinOpWithConstant(ICmpInst &Cmp, BinaryOperator *BO,
678 const APInt &C);
679 Instruction *foldICmpSelectConstant(ICmpInst &Cmp, SelectInst *Select,
680 ConstantInt *C);
681 Instruction *foldICmpTruncConstant(ICmpInst &Cmp, TruncInst *Trunc,
682 const APInt &C);
683 Instruction *foldICmpTruncWithTruncOrExt(ICmpInst &Cmp,
684 const SimplifyQuery &Q);
685 Instruction *foldICmpAndConstant(ICmpInst &Cmp, BinaryOperator *And,
686 const APInt &C);
687 Instruction *foldICmpXorConstant(ICmpInst &Cmp, BinaryOperator *Xor,
688 const APInt &C);
689 Instruction *foldICmpOrConstant(ICmpInst &Cmp, BinaryOperator *Or,
690 const APInt &C);
691 Instruction *foldICmpMulConstant(ICmpInst &Cmp, BinaryOperator *Mul,
692 const APInt &C);
693 Instruction *foldICmpShlConstant(ICmpInst &Cmp, BinaryOperator *Shl,
694 const APInt &C);
695 Instruction *foldICmpShrConstant(ICmpInst &Cmp, BinaryOperator *Shr,
696 const APInt &C);
697 Instruction *foldICmpSRemConstant(ICmpInst &Cmp, BinaryOperator *UDiv,
698 const APInt &C);
699 Instruction *foldICmpUDivConstant(ICmpInst &Cmp, BinaryOperator *UDiv,
700 const APInt &C);
701 Instruction *foldICmpDivConstant(ICmpInst &Cmp, BinaryOperator *Div,
702 const APInt &C);
703 Instruction *foldICmpSubConstant(ICmpInst &Cmp, BinaryOperator *Sub,
704 const APInt &C);
705 Instruction *foldICmpAddConstant(ICmpInst &Cmp, BinaryOperator *Add,
706 const APInt &C);
707 Instruction *foldICmpAndConstConst(ICmpInst &Cmp, BinaryOperator *And,
708 const APInt &C1);
709 Instruction *foldICmpAndShift(ICmpInst &Cmp, BinaryOperator *And,
710 const APInt &C1, const APInt &C2);
711 Instruction *foldICmpXorShiftConst(ICmpInst &Cmp, BinaryOperator *Xor,
712 const APInt &C);
713 Instruction *foldICmpShrConstConst(ICmpInst &I, Value *ShAmt, const APInt &C1,
714 const APInt &C2);
715 Instruction *foldICmpShlConstConst(ICmpInst &I, Value *ShAmt, const APInt &C1,
716 const APInt &C2);
717
718 Instruction *foldICmpBinOpEqualityWithConstant(ICmpInst &Cmp,
719 BinaryOperator *BO,
720 const APInt &C);
721 Instruction *foldICmpIntrinsicWithConstant(ICmpInst &ICI, IntrinsicInst *II,
722 const APInt &C);
723 Instruction *foldICmpEqIntrinsicWithConstant(ICmpInst &ICI, IntrinsicInst *II,
724 const APInt &C);
725 Instruction *foldICmpBitCast(ICmpInst &Cmp);
726 Instruction *foldICmpWithTrunc(ICmpInst &Cmp);
727 Instruction *foldICmpCommutative(ICmpInst::Predicate Pred, Value *Op0,
728 Value *Op1, ICmpInst &CxtI);
729
730 // Helpers of visitSelectInst().
733 Instruction *foldSelectOpOp(SelectInst &SI, Instruction *TI, Instruction *FI);
734 Instruction *foldSelectIntoOp(SelectInst &SI, Value *, Value *);
736 Value *A, Value *B, Instruction &Outer,
741 unsigned Depth = 0);
742
743 Value *insertRangeTest(Value *V, const APInt &Lo, const APInt &Hi,
744 bool isSigned, bool Inside);
745 bool mergeStoreIntoSuccessor(StoreInst &SI);
746
747 /// Given an initial instruction, check to see if it is the root of a
748 /// bswap/bitreverse idiom. If so, return the equivalent bswap/bitreverse
749 /// intrinsic.
750 Instruction *matchBSwapOrBitReverse(Instruction &I, bool MatchBSwaps,
751 bool MatchBitReversals);
752
753 Instruction *SimplifyAnyMemTransfer(AnyMemTransferInst *MI);
754 Instruction *SimplifyAnyMemSet(AnyMemSetInst *MI);
755
756 Value *EvaluateInDifferentType(Value *V, Type *Ty, bool isSigned);
757
758 bool tryToSinkInstruction(Instruction *I, BasicBlock *DestBlock);
759 void tryToSinkInstructionDbgValues(
760 Instruction *I, BasicBlock::iterator InsertPos, BasicBlock *SrcBlock,
762 void tryToSinkInstructionDbgVariableRecords(
763 Instruction *I, BasicBlock::iterator InsertPos, BasicBlock *SrcBlock,
765
766 bool removeInstructionsBeforeUnreachable(Instruction &I);
767 void addDeadEdge(BasicBlock *From, BasicBlock *To,
769 void handleUnreachableFrom(Instruction *I,
771 void handlePotentiallyDeadBlocks(SmallVectorImpl<BasicBlock *> &Worklist);
772 void handlePotentiallyDeadSuccessors(BasicBlock *BB, BasicBlock *LiveSucc);
773 void freelyInvertAllUsersOf(Value *V, Value *IgnoredUser = nullptr);
774};
775
776class Negator final {
777 /// Top-to-bottom, def-to-use negated instruction tree we produced.
779
781 BuilderTy Builder;
782
783 const bool IsTrulyNegation;
784
785 SmallDenseMap<Value *, Value *> NegationsCache;
786
787 Negator(LLVMContext &C, const DataLayout &DL, bool IsTrulyNegation);
788
789#if LLVM_ENABLE_STATS
790 unsigned NumValuesVisitedInThisNegator = 0;
791 ~Negator();
792#endif
793
794 using Result = std::pair<ArrayRef<Instruction *> /*NewInstructions*/,
795 Value * /*NegatedRoot*/>;
796
797 std::array<Value *, 2> getSortedOperandsOfBinOp(Instruction *I);
798
799 [[nodiscard]] Value *visitImpl(Value *V, bool IsNSW, unsigned Depth);
800
801 [[nodiscard]] Value *negate(Value *V, bool IsNSW, unsigned Depth);
802
803 /// Recurse depth-first and attempt to sink the negation.
804 /// FIXME: use worklist?
805 [[nodiscard]] std::optional<Result> run(Value *Root, bool IsNSW);
806
807 Negator(const Negator &) = delete;
808 Negator(Negator &&) = delete;
809 Negator &operator=(const Negator &) = delete;
810 Negator &operator=(Negator &&) = delete;
811
812public:
813 /// Attempt to negate \p Root. Retuns nullptr if negation can't be performed,
814 /// otherwise returns negated value.
815 [[nodiscard]] static Value *Negate(bool LHSIsZero, bool IsNSW, Value *Root,
816 InstCombinerImpl &IC);
817};
818
819} // end namespace llvm
820
821#undef DEBUG_TYPE
822
823#endif // LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
amdgpu AMDGPU Register Bank Select
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static bool foldICmpWithDominatingICmp(CmpInst *Cmp, const TargetLowering &TLI)
For pattern like:
#define LLVM_LIBRARY_VISIBILITY
Definition: Compiler.h:131
static bool willNotOverflow(BinaryOpIntrinsic *BO, LazyValueInfo *LVI)
#define LLVM_DEBUG(X)
Definition: Debug.h:101
uint64_t Align
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static bool isSigned(unsigned int Opcode)
Hexagon Common GEP
IRTranslator LLVM IR MI
static constexpr unsigned NegatorMaxNodesSSO
static constexpr unsigned NegatorDefaultMaxDepth
This file provides the interface for the instcombine pass implementation.
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
static OverflowResult computeOverflowForSignedAdd(const WithCache< const Value * > &LHS, const WithCache< const Value * > &RHS, const AddOperator *Add, const SimplifyQuery &SQ)
Value * RHS
Value * LHS
BinaryOperator * Mul
support::ulittle16_t & Lo
Definition: aarch32.cpp:206
support::ulittle16_t & Hi
Definition: aarch32.cpp:205
static const uint32_t IV[8]
Definition: blake3_impl.h:78
Class for arbitrary precision integers.
Definition: APInt.h:76
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
Definition: Instructions.h:59
This class represents any memset intrinsic.
A cache of @llvm.assume calls within a function.
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:748
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:165
This class represents a no-op cast from one type to another.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Conditional or Unconditional Branch instruction.
Analysis providing branch probability information.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1494
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:601
This class is the base class for the comparison instructions.
Definition: InstrTypes.h:983
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:993
This is the shared class of boolean and integer constants.
Definition: Constants.h:80
This is an important base class in LLVM.
Definition: Constant.h:41
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:162
This instruction extracts a single (scalar) element from a VectorType value.
This instruction extracts a struct member or array element value from an aggregate value.
This instruction compares its operands according to the predicate given to the constructor.
This class represents a cast from floating point to signed integer.
This class represents a cast from floating point to unsigned integer.
This class represents a truncation of floating point types.
Convenience struct for specifying and reasoning about fast-math flags.
Definition: FMF.h:20
An instruction for ordering other memory operations.
Definition: Instructions.h:460
This class represents a freeze function that returns random concrete value if an operand is either a ...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition: Instructions.h:973
This instruction compares its operands according to the predicate given to the constructor.
This instruction inserts a single (scalar) element into a VectorType value.
This instruction inserts a struct field of array element value into an aggregate value.
bool fmulByZeroIsZero(Value *MulVal, FastMathFlags FMF, const Instruction *CtxI) const
Check if fmul MulVal, +0.0 will yield +0.0 (or signed zero is ignorable).
virtual ~InstCombinerImpl()=default
KnownFPClass computeKnownFPClass(Value *Val, FastMathFlags FMF, FPClassTest Interested=fcAllFlags, const Instruction *CtxI=nullptr, unsigned Depth=0) const
Instruction * foldVectorSelect(SelectInst &Sel)
Instruction * foldSelectValueEquivalence(SelectInst &SI, ICmpInst &ICI)
Instruction * foldSPFofSPF(Instruction *Inner, SelectPatternFlavor SPF1, Value *A, Value *B, Instruction &Outer, SelectPatternFlavor SPF2, Value *C)
Constant * getLosslessUnsignedTrunc(Constant *C, Type *TruncTy)
bool replaceInInstruction(Value *V, Value *Old, Value *New, unsigned Depth=0)
Instruction * eraseInstFromFunction(Instruction &I) override
Combiner aware instruction erasure.
Instruction * foldSelectInstWithICmp(SelectInst &SI, ICmpInst *ICI)
Constant * getLosslessTrunc(Constant *C, Type *TruncTy, unsigned ExtOp)
Instruction * visitInstruction(Instruction &I)
Specify what to return for unhandled instructions.
KnownFPClass computeKnownFPClass(Value *Val, FPClassTest Interested=fcAllFlags, const Instruction *CtxI=nullptr, unsigned Depth=0) const
Constant * getLosslessSignedTrunc(Constant *C, Type *TruncTy)
void CreateNonTerminatorUnreachable(Instruction *InsertAt)
Create and insert the idiom we use to indicate a block is unreachable without having to rewrite the C...
Instruction * visitSelectInst(SelectInst &SI)
Instruction * foldSelectOfBools(SelectInst &SI)
Instruction * foldSelectExtConst(SelectInst &Sel)
InstCombinerImpl(InstructionWorklist &Worklist, BuilderTy &Builder, bool MinimizeSize, AAResults *AA, AssumptionCache &AC, TargetLibraryInfo &TLI, TargetTransformInfo &TTI, DominatorTree &DT, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI)
The core instruction combiner logic.
Definition: InstCombiner.h:47
Base class for instruction visitors.
Definition: InstVisitor.h:78
InstructionWorklist - This is the worklist management logic for InstCombine and other simplification ...
This class represents a cast from an integer to a pointer.
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:47
Invoke instruction.
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
The landingpad instruction holds all of the information necessary to generate correct exception handl...
An instruction for reading from memory.
Definition: Instructions.h:184
This class represents min/max intrinsics.
static Value * Negate(bool LHSIsZero, bool IsNSW, Value *Root, InstCombinerImpl &IC)
Attempt to negate Root.
This is a utility class that provides an abstraction for the common functionality between Instruction...
Definition: Operator.h:31
The optimization diagnostic interface.
Analysis providing profile information.
This class represents a cast from a pointer to an integer.
Return a value (possibly void), from a function.
This class represents a sign extension of integer types.
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
An instruction for storing to memory.
Definition: Instructions.h:317
Multiway switch.
Provides information about what library functions are available for the current target.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
This class represents a truncation of integer types.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
This function has undefined behavior.
This represents the llvm.va_end intrinsic.
LLVM Value Representation.
Definition: Value.h:74
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1074
This class represents zero extension of integer types.
self_iterator getIterator()
Definition: ilist_node.h:109
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OverflowResult
void salvageDebugInfo(const MachineRegisterInfo &MRI, MachineInstr &MI)
Assuming the instruction MI is going to be deleted, attempt to salvage debug users of MI by writing t...
Definition: Utils.cpp:1652
OverflowResult computeOverflowForUnsignedMul(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ, bool IsNSW=false)
OverflowResult computeOverflowForSignedSub(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
SelectPatternFlavor
Specific patterns of select instructions we can match.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
OverflowResult computeOverflowForSignedMul(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
OverflowResult computeOverflowForUnsignedSub(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
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.