Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:SI

26   SelectInst *SI = dyn_cast<SelectInst>(V);
27 if (SI == 0) return SPF_UNKNOWN;
29 ICmpInst *ICI = dyn_cast<ICmpInst>(SI->getCondition());
36 if (SI->getTrueValue() == ICI->getOperand(0) &&
37 SI->getFalseValue() == ICI->getOperand(1)) {
52 if (SI->getTrueValue() == ICI->getOperand(1) &&
53 SI->getFalseValue() == ICI->getOperand(0)) {
124 Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI,
134 Type *CondTy = SI.getCondition()->getType();
143 Value *NewSI = Builder->CreateSelect(SI.getCondition(), TI->getOperand(0),
144 FI->getOperand(0), SI.getName()+".v");
183 Value *NewSI = Builder->CreateSelect(SI.getCondition(), OtherOpT,
184 OtherOpF, SI.getName()+".v");
210 Instruction *InstCombiner::FoldSelectIntoOp(SelectInst &SI, Value *TrueVal,
231 Value *NewSel = Builder->CreateSelect(SI.getCondition(), OOp, C);
266 Value *NewSel = Builder->CreateSelect(SI.getCondition(), C, OOp);
355 Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI,
361 Value *TrueVal = SI.getTrueValue();
362 Value *FalseVal = SI.getFalseValue();
372 return ReplaceInstUsesWith(SI, FalseVal);
376 return ReplaceInstUsesWith(SI, FalseVal);
384 IntegerType *SelectTy = dyn_cast<IntegerType>(SI.getType());
446 SI.setOperand(1, TrueVal);
447 SI.setOperand(2, FalseVal);
451 ICI->moveBefore(&SI);
481 return ReplaceInstUsesWith(SI, Builder->CreateOr(AShr, C1));
484 return ReplaceInstUsesWith(SI, Builder->CreateAdd(And, C1));
496 return ReplaceInstUsesWith(SI, FalseVal);
499 return ReplaceInstUsesWith(SI, FalseVal);
503 return ReplaceInstUsesWith(SI, TrueVal);
506 return ReplaceInstUsesWith(SI, TrueVal);
514 SI.setOperand(1, CmpRHS);
518 SI.setOperand(2, CmpRHS);
523 return Changed ? &SI : 0;
527 /// CanSelectOperandBeMappingIntoPredBlock - SI is a select whose condition is a
539 const SelectInst &SI) {
547 const PHINode *CondPHI = cast<PHINode>(SI.getCondition());
555 if (SI.getParent() == CondPHI->getParent() &&
595 static Value *foldSelectICmpAnd(const SelectInst &SI, ConstantInt *TrueVal,
598 const ICmpInst *IC = dyn_cast<ICmpInst>(SI.getCondition());
607 if (LHS->getType() != SI.getType() ||
661 Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
662 Value *CondVal = SI.getCondition();
663 Value *TrueVal = SI.getTrueValue();
664 Value *FalseVal = SI.getFalseValue();
667 return ReplaceInstUsesWith(SI, V);
669 if (SI.getType()->isIntegerTy(1)) {
708 return new ZExtInst(CondVal, SI.getType());
712 return new SExtInst(CondVal, SI.getType());
717 return new ZExtInst(NotCond, SI.getType());
723 return new SExtInst(NotCond, SI.getType());
726 if (Value *V = foldSelectICmpAnd(SI, TrueValC, FalseValC, Builder))
727 return ReplaceInstUsesWith(SI, V);
743 return ReplaceInstUsesWith(SI, FalseVal);
755 return ReplaceInstUsesWith(SI, TrueVal);
770 return ReplaceInstUsesWith(SI, FalseVal);
782 return ReplaceInstUsesWith(SI, TrueVal);
791 if (Instruction *Result = visitSelectInstWithICmp(SI, ICI))
801 if (Instruction *IV = FoldSelectOpOp(SI, TI, FI))
830 if (SI.getType()->isFPOrFPVectorTy()) {
842 NewFalseOp, SI.getName() + ".p");
844 if (SI.getType()->isFPOrFPVectorTy())
853 if (SI.getType()->isIntegerTy()) {
854 if (Instruction *FoldI = FoldSelectIntoOp(SI, TrueVal, FalseVal))
862 if (SelectPatternFlavor SPF = MatchSelectPattern(&SI, LHS, RHS)) {
865 SI, SPF, RHS))
869 SI, SPF, LHS))
879 if (isa<PHINode>(SI.getCondition()))
881 if (CanSelectOperandBeMappingIntoPredBlock(TrueVal, SI) &&
882 CanSelectOperandBeMappingIntoPredBlock(FalseVal, SI))
883 if (Instruction *NV = FoldOpIntoPhi(SI))
888 if (SI.getTrueValue() == TrueSI->getTrueValue())
890 SI.setOperand(1, TrueSI->getTrueValue());
891 return &SI;
896 if (SI.getFalseValue() == FalseSI->getFalseValue())
898 SI.setOperand(2, FalseSI->getFalseValue());
899 return &SI;
904 SI.setOperand(0, BinaryOperator::getNotArgument(CondVal));
905 SI.setOperand(1, FalseVal);
906 SI.setOperand(2, TrueVal);
907 return &SI;
910 if (VectorType *VecTy = dyn_cast<VectorType>(SI.getType())) {
914 if (Value *V = SimplifyDemandedVectorElts(&SI, AllOnesEltMask, UndefElts)) {
915 if (V != &SI)
916 return ReplaceInstUsesWith(SI, V);
917 return &SI;
935 return ReplaceInstUsesWith(SI, V);
939 return ReplaceInstUsesWith(SI, FalseVal);