@@ -3198,80 +3198,79 @@ bool SPIRVInstructionSelector::selectFirstBitSet64Overflow(
3198
3198
GR.getOrCreateSPIRVVectorType (OpType, LeftComponentCount, MIRBuilder);
3199
3199
LeftVecResType =
3200
3200
GR.getOrCreateSPIRVVectorType (BaseType, LeftComponentCount, MIRBuilder);
3201
- } else {
3202
- LeftVecOpType = OpType;
3203
- LeftVecResType = BaseType;
3204
- }
3205
-
3206
- SPIRVType *RightVecOpType =
3207
- GR.getOrCreateSPIRVVectorType (OpType, RightComponentCount, MIRBuilder);
3208
- SPIRVType *RightVecResType = GR.getOrCreateSPIRVVectorType (
3209
- BaseType, RightComponentCount, MIRBuilder);
3210
-
3211
- Register LeftSideIn =
3212
- MRI->createVirtualRegister (GR.getRegClass (LeftVecOpType));
3213
- Register RightSideIn =
3214
- MRI->createVirtualRegister (GR.getRegClass (RightVecOpType));
3215
-
3216
- bool Result;
3201
+ } else {
3202
+ LeftVecOpType = OpType;
3203
+ LeftVecResType = BaseType;
3204
+ }
3217
3205
3218
- // Extract the left half from the SrcReg into LeftSideIn
3219
- // accounting for the special case when it only has one element
3220
- if (LeftIsVector) {
3221
- auto MIB =
3222
- BuildMI (*I.getParent (), I, I.getDebugLoc (),
3223
- TII.get (SPIRV::OpVectorShuffle))
3224
- .addDef (LeftSideIn)
3225
- .addUse (GR.getSPIRVTypeID (LeftVecOpType))
3226
- .addUse (SrcReg)
3227
- // Per the spec, repeat the vector if only one vec is needed
3228
- .addUse (SrcReg);
3206
+ SPIRVType *RightVecOpType =
3207
+ GR.getOrCreateSPIRVVectorType (OpType, RightComponentCount, MIRBuilder);
3208
+ SPIRVType *RightVecResType =
3209
+ GR.getOrCreateSPIRVVectorType (BaseType, RightComponentCount, MIRBuilder);
3229
3210
3230
- for (unsigned J = 0 ; J < LeftComponentCount; J++) {
3231
- MIB.addImm (J);
3232
- }
3211
+ Register LeftSideIn =
3212
+ MRI->createVirtualRegister (GR.getRegClass (LeftVecOpType));
3213
+ Register RightSideIn =
3214
+ MRI->createVirtualRegister (GR.getRegClass (RightVecOpType));
3233
3215
3234
- Result = MIB.constrainAllUses (TII, TRI, RBI);
3235
- } else {
3236
- Result =
3237
- selectOpWithSrcs (LeftSideIn, LeftVecOpType, I, {SrcReg, ConstIntZero},
3238
- SPIRV::OpVectorExtractDynamic);
3239
- }
3216
+ bool Result;
3240
3217
3241
- // Extract the right half from the SrcReg into RightSideIn.
3242
- // Right will always be a vector since the only time one element is left is
3243
- // when Component == 3, and in that case Left is one element.
3218
+ // Extract the left half from the SrcReg into LeftSideIn
3219
+ // accounting for the special case when it only has one element
3220
+ if (LeftIsVector) {
3244
3221
auto MIB = BuildMI (*I.getParent (), I, I.getDebugLoc (),
3245
3222
TII.get (SPIRV::OpVectorShuffle))
3246
- .addDef (RightSideIn )
3247
- .addUse (GR.getSPIRVTypeID (RightVecOpType ))
3223
+ .addDef (LeftSideIn )
3224
+ .addUse (GR.getSPIRVTypeID (LeftVecOpType ))
3248
3225
.addUse (SrcReg)
3249
3226
// Per the spec, repeat the vector if only one vec is needed
3250
3227
.addUse (SrcReg);
3251
3228
3252
- for (unsigned J = LeftComponentCount ; J < ComponentCount ; J++) {
3229
+ for (unsigned J = 0 ; J < LeftComponentCount ; J++) {
3253
3230
MIB.addImm (J);
3254
3231
}
3255
3232
3256
- Result = Result && MIB.constrainAllUses (TII, TRI, RBI);
3233
+ Result = MIB.constrainAllUses (TII, TRI, RBI);
3234
+ } else {
3235
+ Result =
3236
+ selectOpWithSrcs (LeftSideIn, LeftVecOpType, I, {SrcReg, ConstIntZero},
3237
+ SPIRV::OpVectorExtractDynamic);
3238
+ }
3257
3239
3258
- // Recursively call selectFirstBitSet64 on the 2 halves
3259
- Register LeftSideOut =
3260
- MRI->createVirtualRegister (GR.getRegClass (LeftVecResType));
3261
- Register RightSideOut =
3262
- MRI->createVirtualRegister (GR.getRegClass (RightVecResType));
3263
- Result = Result &&
3264
- selectFirstBitSet64 (LeftSideOut, LeftVecResType, I, LeftSideIn,
3265
- BitSetOpcode, SwapPrimarySide);
3266
- Result = Result &&
3267
- selectFirstBitSet64 (RightSideOut, RightVecResType, I, RightSideIn,
3268
- BitSetOpcode, SwapPrimarySide);
3269
-
3270
- // Join the two resulting registers back into the return type
3271
- // (ie i32x2, i32x2 -> i32x4)
3272
- return Result &&
3273
- selectOpWithSrcs (ResVReg, ResType, I, {LeftSideOut, RightSideOut},
3274
- SPIRV::OpCompositeConstruct);
3240
+ // Extract the right half from the SrcReg into RightSideIn.
3241
+ // Right will always be a vector since the only time one element is left is
3242
+ // when Component == 3, and in that case Left is one element.
3243
+ auto MIB = BuildMI (*I.getParent (), I, I.getDebugLoc (),
3244
+ TII.get (SPIRV::OpVectorShuffle))
3245
+ .addDef (RightSideIn)
3246
+ .addUse (GR.getSPIRVTypeID (RightVecOpType))
3247
+ .addUse (SrcReg)
3248
+ // Per the spec, repeat the vector if only one vec is needed
3249
+ .addUse (SrcReg);
3250
+
3251
+ for (unsigned J = LeftComponentCount; J < ComponentCount; J++) {
3252
+ MIB.addImm (J);
3253
+ }
3254
+
3255
+ Result = Result && MIB.constrainAllUses (TII, TRI, RBI);
3256
+
3257
+ // Recursively call selectFirstBitSet64 on the 2 halves
3258
+ Register LeftSideOut =
3259
+ MRI->createVirtualRegister (GR.getRegClass (LeftVecResType));
3260
+ Register RightSideOut =
3261
+ MRI->createVirtualRegister (GR.getRegClass (RightVecResType));
3262
+ Result =
3263
+ Result && selectFirstBitSet64 (LeftSideOut, LeftVecResType, I, LeftSideIn,
3264
+ BitSetOpcode, SwapPrimarySide);
3265
+ Result =
3266
+ Result && selectFirstBitSet64 (RightSideOut, RightVecResType, I,
3267
+ RightSideIn, BitSetOpcode, SwapPrimarySide);
3268
+
3269
+ // Join the two resulting registers back into the return type
3270
+ // (ie i32x2, i32x2 -> i32x4)
3271
+ return Result &&
3272
+ selectOpWithSrcs (ResVReg, ResType, I, {LeftSideOut, RightSideOut},
3273
+ SPIRV::OpCompositeConstruct);
3275
3274
}
3276
3275
3277
3276
bool SPIRVInstructionSelector::selectFirstBitSet64 (
0 commit comments