Skip to content

Commit 7b1a8cc

Browse files
committed
format
1 parent e67adb9 commit 7b1a8cc

File tree

1 file changed

+59
-60
lines changed

1 file changed

+59
-60
lines changed

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,80 +3198,79 @@ bool SPIRVInstructionSelector::selectFirstBitSet64Overflow(
31983198
GR.getOrCreateSPIRVVectorType(OpType, LeftComponentCount, MIRBuilder);
31993199
LeftVecResType =
32003200
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+
}
32173205

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);
32293210

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));
32333215

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;
32403217

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) {
32443221
auto MIB = BuildMI(*I.getParent(), I, I.getDebugLoc(),
32453222
TII.get(SPIRV::OpVectorShuffle))
3246-
.addDef(RightSideIn)
3247-
.addUse(GR.getSPIRVTypeID(RightVecOpType))
3223+
.addDef(LeftSideIn)
3224+
.addUse(GR.getSPIRVTypeID(LeftVecOpType))
32483225
.addUse(SrcReg)
32493226
// Per the spec, repeat the vector if only one vec is needed
32503227
.addUse(SrcReg);
32513228

3252-
for (unsigned J = LeftComponentCount; J < ComponentCount; J++) {
3229+
for (unsigned J = 0; J < LeftComponentCount; J++) {
32533230
MIB.addImm(J);
32543231
}
32553232

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+
}
32573239

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);
32753274
}
32763275

32773276
bool SPIRVInstructionSelector::selectFirstBitSet64(

0 commit comments

Comments
 (0)