@@ -93,34 +93,19 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) {
93
93
94
94
Type *VPTypeAnalysis::inferScalarTypeForRecipe (const VPWidenRecipe *R) {
95
95
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)) {
118
98
Type *ResTy = inferScalarType (R->getOperand (0 ));
119
99
assert (ResTy == inferScalarType (R->getOperand (1 )) &&
120
100
" types for both operands must match for binary op" );
121
101
CachedTypes[R->getOperand (1 )] = ResTy;
122
102
return ResTy;
123
103
}
104
+
105
+ switch (Opcode) {
106
+ case Instruction::ICmp:
107
+ case Instruction::FCmp:
108
+ return IntegerType::get (Ctx, 1 );
124
109
case Instruction::FNeg:
125
110
case Instruction::Freeze:
126
111
return inferScalarType (R->getOperand (0 ));
@@ -157,36 +142,26 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPWidenSelectRecipe *R) {
157
142
}
158
143
159
144
Type *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)) {
184
149
Type *ResTy = inferScalarType (R->getOperand (0 ));
185
150
assert (ResTy == inferScalarType (R->getOperand (1 )) &&
186
151
" inferred types for operands of binary op don't match" );
187
152
CachedTypes[R->getOperand (1 )] = ResTy;
188
153
return ResTy;
189
154
}
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
+ }
190
165
case Instruction::Select: {
191
166
Type *ResTy = inferScalarType (R->getOperand (1 ));
192
167
assert (ResTy == inferScalarType (R->getOperand (2 )) &&
@@ -197,21 +172,8 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPReplicateRecipe *R) {
197
172
case Instruction::ICmp:
198
173
case Instruction::FCmp:
199
174
return IntegerType::get (Ctx, 1 );
200
- case Instruction::AddrSpaceCast:
201
175
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:
208
176
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:
215
177
return R->getUnderlyingInstr ()->getType ();
216
178
case Instruction::Freeze:
217
179
case Instruction::FNeg:
0 commit comments