Lines Matching defs:SE

53       function_ref<void(Function &F, LoopInfo &LI, ScalarEvolution &SE)> Test) {
56 ScalarEvolution SE = buildSE(*F);
57 Test(*F, *LI, SE);
60 static std::optional<APInt> computeConstantDifference(ScalarEvolution &SE,
63 return SE.computeConstantDifference(LHS, RHS);
66 static bool matchURem(ScalarEvolution &SE, const SCEV *Expr, const SCEV *&LHS,
68 return SE.matchURem(Expr, LHS, RHS);
72 ScalarEvolution &SE, ICmpInst::Predicate Pred, const SCEV *LHS,
75 return SE.isImpliedCond(Pred, LHS, RHS, FoundPred, FoundLHS, FoundRHS);
92 ScalarEvolution SE = buildSE(*F);
94 const SCEV *S0 = SE.getSCEV(V0);
95 const SCEV *S1 = SE.getSCEV(V1);
96 const SCEV *S2 = SE.getSCEV(V2);
98 const SCEV *P0 = SE.getAddExpr(S0, SE.getConstant(S0->getType(), 2));
99 const SCEV *P1 = SE.getAddExpr(S1, SE.getConstant(S0->getType(), 2));
100 const SCEV *P2 = SE.getAddExpr(S2, SE.getConstant(S0->getType(), 2));
143 ScalarEvolution SE = buildSE(*F);
144 const SCEV *S1 = SE.getSCEV(PN);
145 const SCEV *S2 = SE.getSCEV(PN);
146 const SCEV *ZeroConst = SE.getConstant(Ty, 0);
237 runWithSE(*M, "f_1", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
241 const SCEV *FirstExprForIV0 = SE.getSCEV(IV0);
242 const SCEV *FirstExprForIV0Inc = SE.getSCEV(IV0Inc);
243 const SCEV *SecondExprForIV0 = SE.getSCEV(IV0);
250 auto CheckCommutativeMulExprs = [&](ScalarEvolution &SE, const SCEV *A,
252 EXPECT_EQ(SE.getMulExpr(A, B), SE.getMulExpr(B, A));
253 EXPECT_EQ(SE.getMulExpr(B, C), SE.getMulExpr(C, B));
254 EXPECT_EQ(SE.getMulExpr(A, C), SE.getMulExpr(C, A));
263 const SCEV *Mul0 = SE.getMulExpr(Ops0);
264 const SCEV *Mul1 = SE.getMulExpr(Ops1);
265 const SCEV *Mul2 = SE.getMulExpr(Ops2);
266 const SCEV *Mul3 = SE.getMulExpr(Ops3);
267 const SCEV *Mul4 = SE.getMulExpr(Ops4);
268 const SCEV *Mul5 = SE.getMulExpr(Ops5);
279 *M, FuncName, [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
280 CheckCommutativeMulExprs(SE, SE.getSCEV(getInstructionByName(F, "x")),
281 SE.getSCEV(getInstructionByName(F, "y")),
282 SE.getSCEV(getInstructionByName(F, "z")));
348 ScalarEvolution SE = buildSE(*F);
350 EXPECT_NE(nullptr, SE.getSCEV(Acc[0]));
385 ScalarEvolution SE = buildSE(*F);
386 const SCEV *A = SE.getSCEV(MulA);
387 const SCEV *B = SE.getSCEV(MulB);
419 ScalarEvolution SE = buildSE(*F);
420 EXPECT_NE(nullptr, SE.getSCEV(Mul1));
427 auto *AddWithNUW = cast<SCEVAddExpr>(SE.getAddExpr(
428 SE.getAddExpr(SE.getSCEV(A2), SE.getSCEV(A3), SCEV::FlagNUW),
429 SE.getConstant(APInt(/*numBits=*/32, 5)), SCEV::FlagNUW));
434 SE.getAddExpr(SE.getSCEV(A3), SE.getSCEV(A4), SCEV::FlagAnyWrap);
436 SE.getAddExpr(AddWithAnyWrap, SE.getSCEV(A5), SCEV::FlagNUW));
440 const SCEV *AddWithNSW = SE.getAddExpr(
441 SE.getSCEV(A2), SE.getConstant(APInt(32, 99)), SCEV::FlagNSW);
443 SE.getAddExpr(AddWithNSW, SE.getSCEV(A5), SCEV::FlagNUW));
448 SE.getAddExpr(SE.getSCEV(A2), SE.getSCEV(A4),
451 SE.getAddExpr(AddWithNSWNUW, SE.getSCEV(A5), SCEV::FlagNUW));
456 SE.getAddExpr(AddWithNSW, SE.getSCEV(A6),
523 runWithSE(*M, "f_1", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
527 auto *S0 = cast<SCEVAddRecExpr>(SE.getSCEV(&I0));
530 auto *N0 = normalizeForPostIncUse(S0, Loops, SE);
531 auto *D0 = denormalizeForPostIncUse(N0, Loops, SE);
534 auto *S1 = cast<SCEVAddRecExpr>(SE.getSCEV(&I1));
537 auto *N1 = normalizeForPostIncUse(S1, Loops, SE);
538 auto *D1 = denormalizeForPostIncUse(N1, Loops, SE);
542 runWithSE(*M, "f_2", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
547 auto GetAddRec = [&SE](const Loop *L, std::initializer_list<const SCEV *> Ops) {
549 return SE.getAddRecExpr(OpsCopy, L, SCEV::FlagAnyWrap);
552 auto GetAdd = [&SE](std::initializer_list<const SCEV *> Ops) {
554 return SE.getAddExpr(OpsCopy, SCEV::FlagAnyWrap);
563 const SCEV *V0 = SE.getSCEV(&*F.arg_begin());
564 const SCEV *V1 = SE.getSCEV(&*std::next(F.arg_begin(), 1));
565 const SCEV *V2 = SE.getSCEV(&*std::next(F.arg_begin(), 2));
566 const SCEV *V3 = SE.getSCEV(&*std::next(F.arg_begin(), 3));
603 auto *N = llvm::normalizeForPostIncUse(S, LoopSet, SE);
604 auto *D = llvm::denormalizeForPostIncUse(N, LoopSet, SE);
611 auto *D = llvm::denormalizeForPostIncUse(S, LoopSet, SE);
612 auto *N = llvm::normalizeForPostIncUse(D, LoopSet, SE);
706 ScalarEvolution SE = buildSE(*F);
707 const SCEV *S = SE.getSCEV(Accum);
708 S = SE.getLosslessPtrToIntExpr(S);
710 SE.getZeroExtendExpr(S, I128Ty);
773 ScalarEvolution SE = buildSE(*F);
775 const SCEV *EC = SE.getBackedgeTakenCount(Loop);
782 const SCEV *Five = SE.getConstant(APInt(/*numBits=*/64, 5));
784 SE.getAddRecExpr(Five, SE.getOne(T_int64), Loop, SCEV::FlagAnyWrap);
785 const SCEV *ARAtLoopExit = SE.getSCEVAtScope(AR, nullptr);
791 SE.forgetLoop(Loop);
799 const SCEV *NewEC = SE.getBackedgeTakenCount(Loop);
803 const SCEV *NewARAtLoopExit = SE.getSCEVAtScope(AR, nullptr);
873 ScalarEvolution SE = buildSE(*F);
875 const SCEV *EC = SE.getBackedgeTakenCount(Loop);
879 SE.forgetValue(Load);
888 const SCEV *NewEC = SE.getBackedgeTakenCount(Loop);
944 ScalarEvolution SE = buildSE(*F);
945 const SCEV *Expr = SE.getSCEV(Phi);
948 auto Result = SE.createAddRecFromPHIWithCasts(cast<SCEVUnknown>(Expr));
1002 ScalarEvolution SE = buildSE(*F);
1003 const SCEV *Expr = SE.getSCEV(Phi);
1006 auto Result = SE.createAddRecFromPHIWithCasts(cast<SCEVUnknown>(Expr));
1021 ScalarEvolution SE = buildSE(*F);
1024 const SCEV *ArgSCEV = SE.getSCEV(Arg);
1027 const SCEV *A0 = SE.getNegativeSCEV(ArgSCEV);
1028 const SCEV *A1 = SE.getTruncateExpr(A0, Int32Ty);
1029 const SCEV *A = SE.getNegativeSCEV(A1);
1031 const SCEV *B0 = SE.getTruncateExpr(ArgSCEV, Int32Ty);
1032 const SCEV *B = SE.getNegativeSCEV(B0);
1034 const SCEV *Expr = SE.getAddExpr(A, B);
1036 const SCEV *ZeroConst = SE.getConstant(Int32Ty, 0);
1076 ScalarEvolution SE = buildSE(*F);
1078 const SCEV *AS = SE.getSCEV(A);
1079 const SCEV *BS = SE.getSCEV(B);
1080 const SCEV *CS = SE.getSCEV(C);
1081 const SCEV *S1S = SE.getSCEV(S1);
1082 const SCEV *S2S = SE.getSCEV(S2);
1112 runWithSE(*M, "foo", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1113 const SCEV *ScevInc = SE.getSCEV(getInstructionByName(F, "inc"));
1159 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1160 const SCEV *ScevV0 = SE.getSCEV(getInstructionByName(F, "v0")); // %pp
1161 const SCEV *ScevV3 = SE.getSCEV(getInstructionByName(F, "v3")); // (3 + %pp)
1163 SE.getSCEV(getInstructionByName(F, "vx")); // (%pp + %x)
1165 const SCEV *ScevVX3 = SE.getSCEV(getInstructionByName(F, "vx3"));
1166 const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1}
1167 const SCEV *ScevXA = SE.getSCEV(getInstructionByName(F, "xa")); // {%pp,+,1}
1169 SE.getSCEV(getInstructionByName(F, "yy")); // {(3 + %pp),+,1}
1170 const SCEV *ScevXB = SE.getSCEV(getInstructionByName(F, "xb")); // {%pp,+,1}
1172 SE.getSCEV(getInstructionByName(F, "iv.next")); // {1,+,1}
1174 const SCEV *ScevIV2 = SE.getSCEV(getInstructionByName(F, "iv2"));
1176 const SCEV *ScevIV2P3 = SE.getSCEV(getInstructionByName(F, "iv2p3"));
1178 const SCEV *ScevIV2PVar = SE.getSCEV(getInstructionByName(F, "iv2pvar"));
1181 SE.getSCEV(getInstructionByName(F, "iv2pvarp3"));
1184 SE.getSCEV(getInstructionByName(F, "iv2pvarm3"));
1187 SE.getSCEV(getInstructionByName(F, "iv2pvarp3m3"));
1189 auto diff = [&SE](const SCEV *LHS, const SCEV *RHS) -> std::optional<int> {
1190 auto ConstantDiffOrNone = computeConstantDifference(SE, LHS, RHS);
1242 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1243 const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1}
1244 const SCEV *ScevI = SE.getSCEV(getArgByName(F, "i")); // {0,+,1}
1248 SE.getUMinExpr(ScevI, SE.getConstant(ScevI->getType(), 17));
1250 SCEVParameterRewriter::rewrite(ScevIV, SE, RewriteMap);
1256 SE.getUMinExpr(ScevI, SE.getConstant(ScevI->getType(), 17)));
1257 EXPECT_EQ(AR->getStepRecurrence(SE),
1258 cast<SCEVAddRecExpr>(ScevIV)->getStepRecurrence(SE));
1273 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1274 const SCEV *X = SE.getSCEV(getArgByName(F, "x"));
1275 const SCEV *One = SE.getOne(X->getType());
1276 const SCEV *Sum = SE.getAddExpr(X, One, SCEV::FlagNUW);
1277 EXPECT_TRUE(SE.isKnownPredicate(ICmpInst::ICMP_UGE, Sum, X));
1278 EXPECT_TRUE(SE.isKnownPredicate(ICmpInst::ICMP_UGT, Sum, X));
1299 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1300 const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1}
1301 const SCEV *ScevI = SE.getSCEV(getArgByName(F, "i"));
1302 EXPECT_EQ(SE.getUnsignedRange(ScevIV).getLower(), 0);
1303 EXPECT_EQ(SE.getUnsignedRange(ScevIV).getUpper(), 16);
1305 const SCEV *Add = SE.getAddExpr(ScevI, ScevIV);
1308 SE.getUMinExpr(ScevI, SE.getConstant(ScevI->getType(), 17));
1310 SCEVParameterRewriter::rewrite(Add, SE, RewriteMap);
1311 EXPECT_EQ(SE.getUnsignedRange(AddWithUMin).getLower(), 0);
1312 EXPECT_EQ(SE.getUnsignedRange(AddWithUMin).getUpper(), 33);
1337 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1338 const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1}
1341 const SCEV *BTC = SE.getBackedgeTakenCount(L);
1343 const SCEV *MaxBTC = SE.getConstantMaxBackedgeTakenCount(L);
1372 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1373 const SCEV *X = SE.getSCEV(getInstructionByName(F, "x"));
1375 EXPECT_TRUE(SE.isKnownPredicateAt(ICmpInst::ICMP_NE, X,
1376 SE.getZero(X->getType()), Context));
1401 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1402 const SCEV *X = SE.getSCEV(getInstructionByName(F, "x"));
1403 const SCEV *Y = SE.getSCEV(getInstructionByName(F, "y"));
1407 SE.isBasicBlockEntryGuardedByCond(Guarded, ICmpInst::ICMP_ULT, Y, X));
1409 SE.isBasicBlockEntryGuardedByCond(Guarded, ICmpInst::ICMP_UGT, X, Y));
1444 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1445 const SCEV *IV = SE.getSCEV(getInstructionByName(F, "iv"));
1446 const SCEV *Zero = SE.getZero(IV->getType());
1454 // EXPECT_TRUE(SE.isBasicBlockEntryGuardedByCond(Backedge,
1480 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1483 const SCEV *Zero = SE.getZero(Ty);
1484 const SCEV *MinusOne = SE.getMinusOne(Ty);
1486 const SCEV *AddRec_0_1 = SE.getSCEV(IV);
1488 const SCEV *AddRec_0_N1 = SE.getNegativeSCEV(AddRec_0_1);
1491 EXPECT_TRUE(isImpliedCond(SE, ICmpInst::ICMP_SLT, AddRec_0_N1, Zero,
1494 EXPECT_TRUE(isImpliedCond(SE, ICmpInst::ICMP_SGT, AddRec_0_1, Zero,
1521 runWithSE(*M, "test", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1524 auto *S = SE.getSCEV(URemI);
1526 EXPECT_TRUE(matchURem(SE, S, LHS, RHS));
1527 EXPECT_EQ(LHS, SE.getSCEV(URemI->getOperand(0)));
1528 EXPECT_EQ(RHS, SE.getSCEV(URemI->getOperand(1)));
1537 auto *S = SE.getSCEV(Ext);
1539 EXPECT_TRUE(matchURem(SE, S, LHS, RHS));
1540 EXPECT_NE(LHS, SE.getSCEV(URem1->getOperand(0)));
1544 cast<SCEVConstant>(SE.getSCEV(URem1->getOperand(1)))
1563 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1573 const SCEV *NS = SE.getConstant(NInt);
1574 const SCEV *DS = SE.getConstant(DInt);
1575 auto *FloorS = cast<SCEVConstant>(SE.getUDivExpr(NS, DS));
1576 auto *CeilingS = cast<SCEVConstant>(SE.getUDivCeilSCEV(NS, DS));
1590 ScalarEvolution SE = buildSE(*F);
1594 dyn_cast<SCEVConstant>(SE.getPowerOfTwo(Type::getInt64Ty(Context), i))
1625 runWithSE(*M, "test", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1626 const SCEV *TCScev = SE.getSCEV(getArgByName(F, "num"));
1627 const SCEV *ApplyLoopGuardsTC = SE.applyLoopGuards(TCScev, *LI.begin());
1630 const SCEV *Constant4 = SE.getConstant(Four);
1631 const SCEV *Max = SE.getUMaxExpr(TCScev, Constant4);
1632 const SCEV *Mul = SE.getMulExpr(SE.getUDivExpr(Max, Constant4), Constant4);
1660 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1664 auto *ExtractValueScev = SE.getSCEV(ExtractValue);
1667 SE.forgetValue(IV);
1668 auto *ExtractValueScevForgotten = SE.getExistingSCEV(ExtractValue);
1702 runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1705 SE.getSCEV(F.getEntryBlock().getTerminator()->getOperand(0));