@@ -93,34 +93,19 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) {
9393
9494Type *VPTypeAnalysis::inferScalarTypeForRecipe (const VPWidenRecipe *R) {
9595 unsigned Opcode = R->getOpcode ();
96- switch (Opcode) {
97- case Instruction::ICmp:
98- case Instruction::FCmp:
99- return IntegerType::get (Ctx, 1 );
100- case Instruction::UDiv:
101- case Instruction::SDiv:
102- case Instruction::SRem:
103- case Instruction::URem:
104- case Instruction::Add:
105- case Instruction::FAdd:
106- case Instruction::Sub:
107- case Instruction::FSub:
108- case Instruction::Mul:
109- case Instruction::FMul:
110- case Instruction::FDiv:
111- case Instruction::FRem:
112- case Instruction::Shl:
113- case Instruction::LShr:
114- case Instruction::AShr:
115- case Instruction::And:
116- case Instruction::Or:
117- case Instruction::Xor: {
96+ if (Instruction::isBinaryOp (Opcode) || Instruction::isShift (Opcode) ||
97+ Instruction::isBitwiseLogicOp (Opcode)) {
11898 Type *ResTy = inferScalarType (R->getOperand (0 ));
11999 assert (ResTy == inferScalarType (R->getOperand (1 )) &&
120100 " types for both operands must match for binary op" );
121101 CachedTypes[R->getOperand (1 )] = ResTy;
122102 return ResTy;
123103 }
104+
105+ switch (Opcode) {
106+ case Instruction::ICmp:
107+ case Instruction::FCmp:
108+ return IntegerType::get (Ctx, 1 );
124109 case Instruction::FNeg:
125110 case Instruction::Freeze:
126111 return inferScalarType (R->getOperand (0 ));
@@ -157,36 +142,26 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPWidenSelectRecipe *R) {
157142}
158143
159144Type *VPTypeAnalysis::inferScalarTypeForRecipe (const VPReplicateRecipe *R) {
160- switch (R->getUnderlyingInstr ()->getOpcode ()) {
161- case Instruction::Call: {
162- unsigned CallIdx = R->getNumOperands () - (R->isPredicated () ? 2 : 1 );
163- return cast<Function>(R->getOperand (CallIdx)->getLiveInIRValue ())
164- ->getReturnType ();
165- }
166- case Instruction::UDiv:
167- case Instruction::SDiv:
168- case Instruction::SRem:
169- case Instruction::URem:
170- case Instruction::Add:
171- case Instruction::FAdd:
172- case Instruction::Sub:
173- case Instruction::FSub:
174- case Instruction::Mul:
175- case Instruction::FMul:
176- case Instruction::FDiv:
177- case Instruction::FRem:
178- case Instruction::Shl:
179- case Instruction::LShr:
180- case Instruction::AShr:
181- case Instruction::And:
182- case Instruction::Or:
183- case Instruction::Xor: {
145+ unsigned Opcode = R->getUnderlyingInstr ()->getOpcode ();
146+
147+ if (Instruction::isBinaryOp (Opcode) || Instruction::isShift (Opcode) ||
148+ Instruction::isBitwiseLogicOp (Opcode)) {
184149 Type *ResTy = inferScalarType (R->getOperand (0 ));
185150 assert (ResTy == inferScalarType (R->getOperand (1 )) &&
186151 " inferred types for operands of binary op don't match" );
187152 CachedTypes[R->getOperand (1 )] = ResTy;
188153 return ResTy;
189154 }
155+
156+ if (Instruction::isCast (Opcode))
157+ return R->getUnderlyingInstr ()->getType ();
158+
159+ switch (Opcode) {
160+ case Instruction::Call: {
161+ unsigned CallIdx = R->getNumOperands () - (R->isPredicated () ? 2 : 1 );
162+ return cast<Function>(R->getOperand (CallIdx)->getLiveInIRValue ())
163+ ->getReturnType ();
164+ }
190165 case Instruction::Select: {
191166 Type *ResTy = inferScalarType (R->getOperand (1 ));
192167 assert (ResTy == inferScalarType (R->getOperand (2 )) &&
@@ -197,21 +172,8 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPReplicateRecipe *R) {
197172 case Instruction::ICmp:
198173 case Instruction::FCmp:
199174 return IntegerType::get (Ctx, 1 );
200- case Instruction::AddrSpaceCast:
201175 case Instruction::Alloca:
202- case Instruction::BitCast:
203- case Instruction::Trunc:
204- case Instruction::SExt:
205- case Instruction::ZExt:
206- case Instruction::FPExt:
207- case Instruction::FPTrunc:
208176 case Instruction::ExtractValue:
209- case Instruction::SIToFP:
210- case Instruction::UIToFP:
211- case Instruction::FPToSI:
212- case Instruction::FPToUI:
213- case Instruction::PtrToInt:
214- case Instruction::IntToPtr:
215177 return R->getUnderlyingInstr ()->getType ();
216178 case Instruction::Freeze:
217179 case Instruction::FNeg:
0 commit comments