@@ -1001,24 +1001,22 @@ static void findForkedSCEVs(
1001
1001
break ;
1002
1002
}
1003
1003
1004
- // Find the pointer type we need to extend to.
1005
- Type *IntPtrTy = SE->getEffectiveSCEVType (
1006
- SE->getSCEV (GEP->getPointerOperand ())->getType ());
1004
+ Type *IntPtrTy = SE->getEffectiveSCEVType (GEP->getPointerOperandType ());
1007
1005
1008
1006
// Find the size of the type being pointed to. We only have a single
1009
1007
// index term (guarded above) so we don't need to index into arrays or
1010
1008
// structures, just get the size of the scalar value.
1011
1009
const SCEV *Size = SE->getSizeOfExpr (IntPtrTy, SourceTy);
1012
1010
1013
- // Scale up the offsets by the size of the type, then add to the bases.
1014
- const SCEV *Scaled1 = SE-> getMulExpr (
1015
- Size, SE-> getTruncateOrSignExtend ( get<0 >(OffsetScevs[ 0 ]), IntPtrTy) );
1016
- const SCEV *Scaled2 = SE-> getMulExpr (
1017
- Size, SE-> getTruncateOrSignExtend (get< 0 >(OffsetScevs[ 1 ]), IntPtrTy));
1018
- ScevList. emplace_back (SE-> getAddExpr (get< 0 >(BaseScevs[ 0 ]), Scaled1),
1019
- NeedsFreeze );
1020
- ScevList.emplace_back (SE->getAddExpr (get< 0 >(BaseScevs[ 1 ]), Scaled2),
1021
- NeedsFreeze);
1011
+ for ( auto [B, O] : zip (BaseScevs, OffsetScevs)) {
1012
+ const SCEV *Base = get< 0 >(B);
1013
+ const SCEV *Offset = get<0 >(O );
1014
+
1015
+ // Scale up the offsets by the size of the type, then add to the bases.
1016
+ const SCEV *Scaled =
1017
+ SE-> getMulExpr (Size, SE-> getTruncateOrSignExtend (Offset, IntPtrTy) );
1018
+ ScevList.emplace_back (SE->getAddExpr (Base, Scaled), NeedsFreeze);
1019
+ }
1022
1020
break ;
1023
1021
}
1024
1022
case Instruction::Select: {
@@ -1028,10 +1026,9 @@ static void findForkedSCEVs(
1028
1026
// then we just bail out and return the generic SCEV.
1029
1027
findForkedSCEVs (SE, L, I->getOperand (1 ), ChildScevs, Depth);
1030
1028
findForkedSCEVs (SE, L, I->getOperand (2 ), ChildScevs, Depth);
1031
- if (ChildScevs.size () == 2 ) {
1032
- ScevList.push_back (ChildScevs[0 ]);
1033
- ScevList.push_back (ChildScevs[1 ]);
1034
- } else
1029
+ if (ChildScevs.size () == 2 )
1030
+ append_range (ScevList, ChildScevs);
1031
+ else
1035
1032
ScevList.emplace_back (Scev, !isGuaranteedNotToBeUndefOrPoison (Ptr));
1036
1033
break ;
1037
1034
}
@@ -1044,10 +1041,9 @@ static void findForkedSCEVs(
1044
1041
findForkedSCEVs (SE, L, I->getOperand (0 ), ChildScevs, Depth);
1045
1042
findForkedSCEVs (SE, L, I->getOperand (1 ), ChildScevs, Depth);
1046
1043
}
1047
- if (ChildScevs.size () == 2 ) {
1048
- ScevList.push_back (ChildScevs[0 ]);
1049
- ScevList.push_back (ChildScevs[1 ]);
1050
- } else
1044
+ if (ChildScevs.size () == 2 )
1045
+ append_range (ScevList, ChildScevs);
1046
+ else
1051
1047
ScevList.emplace_back (Scev, !isGuaranteedNotToBeUndefOrPoison (Ptr));
1052
1048
break ;
1053
1049
}
@@ -1074,12 +1070,9 @@ static void findForkedSCEVs(
1074
1070
break ;
1075
1071
}
1076
1072
1077
- ScevList.emplace_back (
1078
- GetBinOpExpr (Opcode, get<0 >(LScevs[0 ]), get<0 >(RScevs[0 ])),
1079
- NeedsFreeze);
1080
- ScevList.emplace_back (
1081
- GetBinOpExpr (Opcode, get<0 >(LScevs[1 ]), get<0 >(RScevs[1 ])),
1082
- NeedsFreeze);
1073
+ for (auto [L, R] : zip (LScevs, RScevs))
1074
+ ScevList.emplace_back (GetBinOpExpr (Opcode, get<0 >(L), get<0 >(R)),
1075
+ NeedsFreeze);
1083
1076
break ;
1084
1077
}
1085
1078
default :
0 commit comments