@@ -6692,6 +6692,7 @@ class HorizontalReduction {
6692
6692
// / Expected number of uses for reduction operations/reduced values.
6693
6693
static bool hasRequiredNumberOfUses (RecurKind Kind, Instruction *I,
6694
6694
bool IsReductionOp) {
6695
+ assert (Kind != RecurKind::None && " Reduction type not set" );
6695
6696
// SelectInst must be used twice while the condition op must have single
6696
6697
// use only.
6697
6698
if (isCmpSel (Kind))
@@ -6795,8 +6796,8 @@ class HorizontalReduction {
6795
6796
if (IsReducedValue)
6796
6797
ReducedVals.push_back (TreeN);
6797
6798
else {
6798
- auto I = ExtraArgs.find (TreeN);
6799
- if (I != ExtraArgs.end () && !I ->second ) {
6799
+ auto ExtraArgsIter = ExtraArgs.find (TreeN);
6800
+ if (ExtraArgsIter != ExtraArgs.end () && !ExtraArgsIter ->second ) {
6800
6801
// Check if TreeN is an extra argument of its parent operation.
6801
6802
if (Stack.size () <= 1 ) {
6802
6803
// TreeN can't be an extra argument as it is a root reduction
@@ -6818,14 +6819,14 @@ class HorizontalReduction {
6818
6819
6819
6820
// Visit left or right.
6820
6821
Value *EdgeVal = TreeN->getOperand (EdgeToVisit);
6821
- auto *I = dyn_cast<Instruction>(EdgeVal);
6822
- if (!I ) {
6822
+ auto *EdgeInst = dyn_cast<Instruction>(EdgeVal);
6823
+ if (!EdgeInst ) {
6823
6824
// Edge value is not a reduction instruction or a leaf instruction.
6824
6825
// (It may be a constant, function argument, or something else.)
6825
6826
markExtraArg (Stack.back (), EdgeVal);
6826
6827
continue ;
6827
6828
}
6828
- RecurKind EdgeRdxKind = getRdxKind (I );
6829
+ RecurKind EdgeRdxKind = getRdxKind (EdgeInst );
6829
6830
// Continue analysis if the next operand is a reduction operation or
6830
6831
// (possibly) a leaf value. If the leaf value opcode is not set,
6831
6832
// the first met operation != reduction operation is considered as the
@@ -6834,25 +6835,26 @@ class HorizontalReduction {
6834
6835
// Each tree node needs to have minimal number of users except for the
6835
6836
// ultimate reduction.
6836
6837
const bool IsRdxInst = EdgeRdxKind == RdxKind;
6837
- if (I != Phi && I != B &&
6838
- hasSameParent (RdxKind, I , B->getParent (), IsRdxInst) &&
6839
- hasRequiredNumberOfUses (RdxKind, I , IsRdxInst) &&
6840
- (!LeafOpcode || LeafOpcode == I ->getOpcode () || IsRdxInst)) {
6838
+ if (EdgeInst != Phi && EdgeInst != B &&
6839
+ hasSameParent (RdxKind, EdgeInst , B->getParent (), IsRdxInst) &&
6840
+ hasRequiredNumberOfUses (RdxKind, EdgeInst , IsRdxInst) &&
6841
+ (!LeafOpcode || LeafOpcode == EdgeInst ->getOpcode () || IsRdxInst)) {
6841
6842
if (IsRdxInst) {
6842
6843
// We need to be able to reassociate the reduction operations.
6843
- if (!isVectorizable (EdgeRdxKind, I )) {
6844
+ if (!isVectorizable (EdgeRdxKind, EdgeInst )) {
6844
6845
// I is an extra argument for TreeN (its parent operation).
6845
- markExtraArg (Stack.back (), I );
6846
+ markExtraArg (Stack.back (), EdgeInst );
6846
6847
continue ;
6847
6848
}
6848
6849
} else if (!LeafOpcode) {
6849
- LeafOpcode = I ->getOpcode ();
6850
+ LeafOpcode = EdgeInst ->getOpcode ();
6850
6851
}
6851
- Stack.push_back (std::make_pair (I, getFirstOperandIndex (EdgeRdxKind)));
6852
+ Stack.push_back (
6853
+ std::make_pair (EdgeInst, getFirstOperandIndex (EdgeRdxKind)));
6852
6854
continue ;
6853
6855
}
6854
6856
// I is an extra argument for TreeN (its parent operation).
6855
- markExtraArg (Stack.back (), I );
6857
+ markExtraArg (Stack.back (), EdgeInst );
6856
6858
}
6857
6859
return true ;
6858
6860
}
0 commit comments