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();
818 static Instruction *foldSetClearBits(SelectInst &Sel,
820 Value *Cond = Sel.getCondition();
821 Value *T = Sel.getTrueValue();
822 Value *F = Sel.getFalseValue();
823 Type *Ty = Sel.getType();
832 Value *NewSel = Builder.CreateSelect(Cond, Zero, OrC, "masksel", &Sel);
841 Value *NewSel = Builder.CreateSelect(Cond, OrC, Zero, "masksel", &Sel);
1286 Instruction *InstCombinerImpl::foldSelectValueEquivalence(SelectInst &Sel,
1292 Value *TrueVal = Sel.getTrueValue(), *FalseVal = Sel.getFalseValue();
1317 isGuaranteedNotToBeUndef(V, SQ.AC, &Sel, &DT))
1318 return replaceOperand(Sel, Swapped ? 2 : 1, V);
1323 if (isGuaranteedNotToBeUndef(NewOp, SQ.AC, &Sel, &DT))
1324 return replaceOperand(Sel, Swapped ? 2 : 1, V);
1338 isGuaranteedNotToBeUndef(NewOp, SQ.AC, &Sel, &DT))
1340 return &Sel;
1373 return replaceInstUsesWith(Sel, FalseVal);
1572 tryToReuseConstantFromSelectInComparison(SelectInst &Sel, ICmpInst &Cmp,
1593 if (C0->getType() != Sel.getType())
1604 match(&Sel, m_Select(m_Value(), m_Value(SelVal0), m_Value(SelVal1)));
1632 IC.Builder.SetInsertPoint(&Sel);
1637 IC.replaceOperand(Sel, 0, NewCmp);
1638 Sel.swapValues();
1639 Sel.swapProfMetadata();
1641 return &Sel;
2213 Instruction *InstCombinerImpl::foldSelectExtConst(SelectInst &Sel) {
2215 if (!match(Sel.getTrueValue(), m_Constant(C)) &&
2216 !match(Sel.getFalseValue(), m_Constant(C)))
2220 if (!match(Sel.getTrueValue(), m_Instruction(ExtInst)) &&
2221 !match(Sel.getFalseValue(), m_Instruction(ExtInst)))
2232 Value *Cond = Sel.getCondition();
2240 Type *SelType = Sel.getType();
2244 if (ExtInst == Sel.getFalseValue())
2249 Value *NewSel = Builder.CreateSelect(Cond, X, TruncCVal, "narrow", &Sel);
2297 static Instruction *canonicalizeScalarSelectOfVecs(SelectInst &Sel,
2299 auto *Ty = dyn_cast<VectorType>(Sel.getType());
2304 Value *Cond = Sel.getCondition();
2312 Sel, 0, IC.Builder.CreateVectorSplat(Ty->getElementCount(), Cond));
2318 static Instruction *foldSelectCmpBitcasts(SelectInst &Sel,
2320 Value *Cond = Sel.getCondition();
2321 Value *TVal = Sel.getTrueValue();
2322 Value *FVal = Sel.getFalseValue();
2351 NewSel = Builder.CreateSelect(Cond, A, B, "", &Sel);
2355 NewSel = Builder.CreateSelect(Cond, B, A, "", &Sel);
2359 return CastInst::CreateBitOrPointerCast(NewSel, Sel.getType());
2438 static Instruction *foldSelectFunnelShift(SelectInst &Sel,
2441 unsigned Width = Sel.getType()->getScalarSizeInBits();
2446 if (!match(Sel.getFalseValue(), m_OneUse(m_Or(m_BinOp(Or0), m_BinOp(Or1)))))
2481 Value *TVal = Sel.getTrueValue();
2486 Value *Cond = Sel.getCondition();
2504 Function *F = Intrinsic::getDeclaration(Sel.getModule(), IID, Sel.getType());
2505 ShAmt = Builder.CreateZExt(ShAmt, Sel.getType());
2509 static Instruction *foldSelectToCopysign(SelectInst &Sel,
2511 Value *Cond = Sel.getCondition();
2512 Value *TVal = Sel.getTrueValue();
2513 Value *FVal = Sel.getFalseValue();
2514 Type *SelType = Sel.getType();
2547 Function *F = Intrinsic::getDeclaration(Sel.getModule(), Intrinsic::copysign,
2548 Sel.getType());
2552 Instruction *InstCombinerImpl::foldVectorSelect(SelectInst &Sel) {
2553 if (!isa<VectorType>(Sel.getType()))
2556 Value *Cond = Sel.getCondition();
2557 Value *TVal = Sel.getTrueValue();
2558 Value *FVal = Sel.getFalseValue();
2563 Value *V = Builder.CreateSelect(C, X, Y, Sel.getName(), &Sel);
2565 I->copyIRFlags(&Sel);
2566 Module *M = Sel.getModule();
2588 auto *VecTy = dyn_cast<FixedVectorType>(Sel.getType());
2595 if (Value *V = SimplifyDemandedVectorElts(&Sel, AllOnesEltMask, PoisonElts)) {
2596 if (V != &Sel)
2597 return replaceInstUsesWith(Sel, V);
2598 return &Sel;
2610 Value *NewSel = Builder.CreateSelect(Cond, Y, X, "sel", &Sel);
2615 Value *NewSel = Builder.CreateSelect(Cond, X, Y, "sel", &Sel);
2624 Value *NewSel = Builder.CreateSelect(Cond, X, Y, "sel", &Sel);
2629 Value *NewSel = Builder.CreateSelect(Cond, Y, X, "sel", &Sel);
2637 static Instruction *foldSelectToPhiImpl(SelectInst &Sel, BasicBlock *BB,
2647 Value *Cond = Sel.getCondition();
2653 IfTrue = Sel.getTrueValue();
2654 IfFalse = Sel.getFalseValue();
2658 IfTrue = Sel.getFalseValue();
2659 IfFalse = Sel.getTrueValue();
2691 auto *PN = Builder.CreatePHI(Sel.getType(), Inputs.size());
2694 PN->takeName(&Sel);
2698 static Instruction *foldSelectToPhi(SelectInst &Sel, const DominatorTree &DT,
2702 CandidateBlocks.insert(Sel.getParent());
2703 for (Value *V : Sel.operands())
2708 if (auto *PN = foldSelectToPhiImpl(Sel, BB, DT, Builder))
2768 static Value *foldSelectWithFrozenICmp(SelectInst &Sel, InstCombiner::BuilderTy &Builder) {
2769 FreezeInst *FI = dyn_cast<FreezeInst>(Sel.getCondition());
2774 Value *TrueVal = Sel.getTrueValue(), *FalseVal = Sel.getFalseValue();