Lines Matching defs:Sel
55 static Instruction *foldSelectBinOpIdentity(SelectInst &Sel,
62 if (!match(Sel.getCondition(), m_Cmp(Pred, m_Value(X), m_Constant(C))))
77 if (!match(Sel.getOperand(IsEq ? 1 : 2), m_BinOp(BO)))
103 IC.getSimplifyQuery().getWithInstruction(&Sel)))
110 return IC.replaceOperand(Sel, IsEq ? 1 : 2, Y);
122 static Value *foldSelectICmpAnd(SelectInst &Sel, ICmpInst *Cmp,
125 if (!match(Sel.getTrueValue(), m_APInt(SelTC)) ||
126 !match(Sel.getFalseValue(), m_APInt(SelFC)))
130 Type *SelType = Sel.getType();
187 if (ConstantFoldBinaryOpOperands(Opc, TCC, MaskC, Sel.getDataLayout()) ==
837 static Instruction *foldSetClearBits(SelectInst &Sel,
839 Value *Cond = Sel.getCondition();
840 Value *T = Sel.getTrueValue();
841 Value *F = Sel.getFalseValue();
842 Type *Ty = Sel.getType();
851 Value *NewSel = Builder.CreateSelect(Cond, Zero, OrC, "masksel", &Sel);
860 Value *NewSel = Builder.CreateSelect(Cond, OrC, Zero, "masksel", &Sel);
1329 Instruction *InstCombinerImpl::foldSelectValueEquivalence(SelectInst &Sel,
1333 Value *TrueVal = Sel.getTrueValue(), *FalseVal = Sel.getFalseValue();
1360 isGuaranteedNotToBeUndef(V, SQ.AC, &Sel, &DT))
1361 return replaceOperand(Sel, Swapped ? 2 : 1, V);
1366 if (isGuaranteedNotToBeUndef(NewOp, SQ.AC, &Sel, &DT))
1367 return replaceOperand(Sel, Swapped ? 2 : 1, V);
1380 isGuaranteedNotToBeUndef(NewOp, SQ.AC, &Sel, &DT))
1382 return &Sel;
1415 return replaceInstUsesWith(Sel, FalseVal);
1433 Instruction *InstCombinerImpl::foldSelectEqualityTest(SelectInst &Sel) {
1435 Value *XeqY, *XeqZ = Sel.getCondition(), *YeqZ = Sel.getTrueValue();
1448 if (!match(Sel.getFalseValue(),
1457 return replaceInstUsesWith(Sel, XeqY);
1653 tryToReuseConstantFromSelectInComparison(SelectInst &Sel, ICmpInst &Cmp,
1674 if (C0->getType() != Sel.getType())
1685 match(&Sel, m_Select(m_Value(), m_Value(SelVal0), m_Value(SelVal1)));
1712 IC.Builder.SetInsertPoint(&Sel);
1717 IC.replaceOperand(Sel, 0, NewCmp);
1718 Sel.swapValues();
1719 Sel.swapProfMetadata();
1721 return &Sel;
2211 Instruction *InstCombinerImpl::foldSelectExtConst(SelectInst &Sel) {
2213 if (!match(Sel.getTrueValue(), m_Constant(C)) &&
2214 !match(Sel.getFalseValue(), m_Constant(C)))
2218 if (!match(Sel.getTrueValue(), m_Instruction(ExtInst)) &&
2219 !match(Sel.getFalseValue(), m_Instruction(ExtInst)))
2230 Value *Cond = Sel.getCondition();
2238 Type *SelType = Sel.getType();
2242 if (ExtInst == Sel.getFalseValue())
2247 Value *NewSel = Builder.CreateSelect(Cond, X, TruncCVal, "narrow", &Sel);
2295 static Instruction *canonicalizeScalarSelectOfVecs(SelectInst &Sel,
2297 auto *Ty = dyn_cast<VectorType>(Sel.getType());
2302 Value *Cond = Sel.getCondition();
2310 Sel, 0, IC.Builder.CreateVectorSplat(Ty->getElementCount(), Cond));
2316 static Instruction *foldSelectCmpBitcasts(SelectInst &Sel,
2318 Value *Cond = Sel.getCondition();
2319 Value *TVal = Sel.getTrueValue();
2320 Value *FVal = Sel.getFalseValue();
2349 NewSel = Builder.CreateSelect(Cond, A, B, "", &Sel);
2353 NewSel = Builder.CreateSelect(Cond, B, A, "", &Sel);
2357 return new BitCastInst(NewSel, Sel.getType());
2436 static Instruction *foldSelectFunnelShift(SelectInst &Sel,
2439 unsigned Width = Sel.getType()->getScalarSizeInBits();
2444 if (!match(Sel.getFalseValue(), m_OneUse(m_Or(m_BinOp(Or0), m_BinOp(Or1)))))
2479 Value *TVal = Sel.getTrueValue();
2484 Value *Cond = Sel.getCondition();
2502 Intrinsic::getOrInsertDeclaration(Sel.getModule(), IID, Sel.getType());
2503 ShAmt = Builder.CreateZExt(ShAmt, Sel.getType());
2507 static Instruction *foldSelectToCopysign(SelectInst &Sel,
2509 Value *Cond = Sel.getCondition();
2510 Value *TVal = Sel.getTrueValue();
2511 Value *FVal = Sel.getFalseValue();
2512 Type *SelType = Sel.getType();
2546 Sel.getModule(), Intrinsic::copysign, Sel.getType());
2550 Instruction *InstCombinerImpl::foldVectorSelect(SelectInst &Sel) {
2551 if (!isa<VectorType>(Sel.getType()))
2554 Value *Cond = Sel.getCondition();
2555 Value *TVal = Sel.getTrueValue();
2556 Value *FVal = Sel.getFalseValue();
2561 Value *V = Builder.CreateSelect(C, X, Y, Sel.getName(), &Sel);
2563 I->copyIRFlags(&Sel);
2564 Module *M = Sel.getModule();
2586 auto *VecTy = dyn_cast<FixedVectorType>(Sel.getType());
2593 if (Value *V = SimplifyDemandedVectorElts(&Sel, AllOnesEltMask, PoisonElts)) {
2594 if (V != &Sel)
2595 return replaceInstUsesWith(Sel, V);
2596 return &Sel;
2608 Value *NewSel = Builder.CreateSelect(Cond, Y, X, "sel", &Sel);
2613 Value *NewSel = Builder.CreateSelect(Cond, X, Y, "sel", &Sel);
2622 Value *NewSel = Builder.CreateSelect(Cond, X, Y, "sel", &Sel);
2627 Value *NewSel = Builder.CreateSelect(Cond, Y, X, "sel", &Sel);
2635 static Instruction *foldSelectToPhiImpl(SelectInst &Sel, BasicBlock *BB,
2645 Value *Cond = Sel.getCondition();
2651 IfTrue = Sel.getTrueValue();
2652 IfFalse = Sel.getFalseValue();
2656 IfTrue = Sel.getFalseValue();
2657 IfFalse = Sel.getTrueValue();
2689 auto *PN = Builder.CreatePHI(Sel.getType(), Inputs.size());
2692 PN->takeName(&Sel);
2696 static Instruction *foldSelectToPhi(SelectInst &Sel, const DominatorTree &DT,
2700 CandidateBlocks.insert(Sel.getParent());
2701 for (Value *V : Sel.operands())
2706 if (auto *PN = foldSelectToPhiImpl(Sel, BB, DT, Builder))
2766 static Value *foldSelectWithFrozenICmp(SelectInst &Sel, InstCombiner::BuilderTy &Builder) {
2767 FreezeInst *FI = dyn_cast<FreezeInst>(Sel.getCondition());
2772 Value *TrueVal = Sel.getTrueValue(), *FalseVal = Sel.getFalseValue();