Skip to content

Commit 688e080

Browse files
committed
apply comment
1 parent 1c16e5c commit 688e080

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -816,21 +816,21 @@ class InstructionsState {
816816
Instruction *AltOp = nullptr;
817817

818818
public:
819-
Instruction *getMainOp() const { return MainOp; }
820-
821-
Instruction *getAltOp() const { return AltOp; }
822-
823-
/// The main/alternate opcodes for the list of instructions.
824-
unsigned getOpcode() const {
819+
Instruction *getMainOp() const {
825820
assert(valid() && "InstructionsState is invalid.");
826-
return getMainOp()->getOpcode();
821+
return MainOp;
827822
}
828823

829-
unsigned getAltOpcode() const {
824+
Instruction *getAltOp() const {
830825
assert(valid() && "InstructionsState is invalid.");
831-
return getAltOp()->getOpcode();
826+
return AltOp;
832827
}
833828

829+
/// The main/alternate opcodes for the list of instructions.
830+
unsigned getOpcode() const { return getMainOp()->getOpcode(); }
831+
832+
unsigned getAltOpcode() const { return getAltOp()->getOpcode(); }
833+
834834
/// Some of the instructions in the list have alternate opcodes.
835835
bool isAltShuffle() const { return getMainOp() != getAltOp(); }
836836

@@ -840,7 +840,7 @@ class InstructionsState {
840840
}
841841

842842
/// Checks if the current state is valid, i.e. has non-null MainOp
843-
bool valid() const { return getMainOp() && getAltOp(); }
843+
bool valid() const { return MainOp && AltOp; }
844844

845845
explicit operator bool() const { return valid(); }
846846

@@ -3406,6 +3406,7 @@ class BoUpSLP {
34063406
}
34073407

34083408
void setOperations(const InstructionsState &S) {
3409+
assert(S && "InstructionsState is invalid.");
34093410
MainOp = S.getMainOp();
34103411
AltOp = S.getAltOp();
34113412
}
@@ -3617,7 +3618,8 @@ class BoUpSLP {
36173618
ReuseShuffleIndices.end());
36183619
if (ReorderIndices.empty()) {
36193620
Last->Scalars.assign(VL.begin(), VL.end());
3620-
Last->setOperations(S);
3621+
if (S)
3622+
Last->setOperations(S);
36213623
} else {
36223624
// Reorder scalars and build final mask.
36233625
Last->Scalars.assign(VL.size(), nullptr);
@@ -3628,7 +3630,8 @@ class BoUpSLP {
36283630
return VL[Idx];
36293631
});
36303632
InstructionsState S = getSameOpcode(Last->Scalars, *TLI);
3631-
Last->setOperations(S);
3633+
if (S)
3634+
Last->setOperations(S);
36323635
Last->ReorderIndices.append(ReorderIndices.begin(), ReorderIndices.end());
36333636
}
36343637
if (!Last->isGather()) {

0 commit comments

Comments
 (0)