Lines Matching refs:Instruction
77 /// Assuming that the specified instruction is an operand to the select, return
78 /// a bitmask indicating which operands of this instruction are foldable if they
81 static unsigned GetSelectFoldableOperands(Instruction *I) {
83 case Instruction::Add:
84 case Instruction::Mul:
85 case Instruction::And:
86 case Instruction::Or:
87 case Instruction::Xor:
89 case Instruction::Sub: // Can only fold on the amount subtracted.
90 case Instruction::Shl: // Can only fold on the shift amount.
91 case Instruction::LShr:
92 case Instruction::AShr:
101 static Constant *GetSelectFoldableConstant(Instruction *I) {
104 case Instruction::Add:
105 case Instruction::Sub:
106 case Instruction::Or:
107 case Instruction::Xor:
108 case Instruction::Shl:
109 case Instruction::LShr:
110 case Instruction::AShr:
112 case Instruction::And:
114 case Instruction::Mul:
120 Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI,
121 Instruction *FI) {
145 if (TI->getOpcode() != Instruction::BitCast &&
159 return CastInst::Create(Instruction::CastOps(TI->getOpcode()), NewSI,
229 Instruction *InstCombiner::FoldSelectIntoOp(SelectInst &SI, Value *TrueVal,
233 if (Instruction *TVI = dyn_cast<Instruction>(TrueVal)) {
263 if (Instruction *FVI = dyn_cast<Instruction>(FalseVal)) {
398 // input to the cttz/ctlz is used as LHS for the compare instruction.
415 Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI,
501 // Move ICI instruction right before the select instruction. Otherwise
502 // the sext/zext value may be defined after the ICI instruction uses it.
625 // If the value is a non-instruction value like a constant or argument, it
627 const Instruction *I = dyn_cast<Instruction>(V);
651 Instruction *InstCombiner::FoldSPFofSPF(Instruction *Inner,
654 Instruction &Outer,
766 /// icmp instruction with zero, and we have an 'and' with the non-constant value
842 static Instruction *foldAddSubSelect(SelectInst &SI,
847 auto *TI = dyn_cast<Instruction>(TrueVal);
848 auto *FI = dyn_cast<Instruction>(FalseVal);
852 Instruction *AddOp = nullptr, *SubOp = nullptr;
853 if ((TI->getOpcode() == Instruction::Sub &&
854 FI->getOpcode() == Instruction::Add) ||
855 (TI->getOpcode() == Instruction::FSub &&
856 FI->getOpcode() == Instruction::FAdd)) {
859 } else if ((FI->getOpcode() == Instruction::Sub &&
860 TI->getOpcode() == Instruction::Add) ||
861 (FI->getOpcode() == Instruction::FSub &&
862 TI->getOpcode() == Instruction::FAdd)) {
881 if (Instruction *NegInst = dyn_cast<Instruction>(NegVal)) {
898 Instruction *RI =
912 Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
1085 if (Instruction *Result = visitSelectInstWithICmp(SI, ICI))
1088 if (Instruction *Add = foldAddSubSelect(SI, *Builder))
1092 auto *TI = dyn_cast<Instruction>(TrueVal);
1093 auto *FI = dyn_cast<Instruction>(FalseVal);
1095 if (Instruction *IV = FoldSelectOpOp(SI, TI, FI))
1100 if (Instruction *FoldI = FoldSelectIntoOp(SI, TrueVal, FalseVal))
1104 Instruction::CastOps CastOp;
1139 if (Instruction *R = FoldSPFofSPF(cast<Instruction>(LHS),SPF2,LHS2,RHS2,
1143 if (Instruction *R = FoldSPFofSPF(cast<Instruction>(RHS),SPF2,LHS2,RHS2,
1184 if (Instruction *NV = FoldOpIntoPhi(SI))