@@ -1536,214 +1536,6 @@ TEST_F(ScalarEvolutionsTest, SCEVUDivFloorCeiling) {
1536
1536
});
1537
1537
}
1538
1538
1539
- TEST_F (ScalarEvolutionsTest, ComputeMaxTripCountFromArrayNormal) {
1540
- LLVMContext C;
1541
- SMDiagnostic Err;
1542
- std::unique_ptr<Module> M = parseAssemblyString (
1543
- " define void @foo(i32 signext %len) { "
1544
- " entry: "
1545
- " %a = alloca [7 x i32], align 4 "
1546
- " %cmp4 = icmp sgt i32 %len, 0 "
1547
- " br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup "
1548
- " for.body.preheader: "
1549
- " br label %for.body "
1550
- " for.cond.cleanup.loopexit: "
1551
- " br label %for.cond.cleanup "
1552
- " for.cond.cleanup: "
1553
- " ret void "
1554
- " for.body: "
1555
- " %iv = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ] "
1556
- " %idxprom = zext i32 %iv to i64 "
1557
- " %arrayidx = getelementptr inbounds [7 x i32], [7 x i32]* %a, i64 0, \
1558
- i64 %idxprom "
1559
- " store i32 0, i32* %arrayidx, align 4 "
1560
- " %inc = add nuw nsw i32 %iv, 1 "
1561
- " %cmp = icmp slt i32 %inc, %len "
1562
- " br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit "
1563
- " } " ,
1564
- Err, C);
1565
-
1566
- ASSERT_TRUE (M && " Could not parse module?" );
1567
- ASSERT_TRUE (!verifyModule (*M) && " Must have been well formed!" );
1568
-
1569
- runWithSE (*M, " foo" , [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1570
- auto *ScevIV = SE.getSCEV (getInstructionByName (F, " iv" ));
1571
- const Loop *L = cast<SCEVAddRecExpr>(ScevIV)->getLoop ();
1572
-
1573
- const SCEV *ITC = SE.getConstantMaxTripCountFromArray (L);
1574
- EXPECT_FALSE (isa<SCEVCouldNotCompute>(ITC));
1575
- EXPECT_TRUE (isa<SCEVConstant>(ITC));
1576
- EXPECT_EQ (cast<SCEVConstant>(ITC)->getAPInt ().getSExtValue (), 8 );
1577
- });
1578
- }
1579
-
1580
- TEST_F (ScalarEvolutionsTest, ComputeMaxTripCountFromZeroArray) {
1581
- LLVMContext C;
1582
- SMDiagnostic Err;
1583
- std::unique_ptr<Module> M = parseAssemblyString (
1584
- " define void @foo(i32 signext %len) { "
1585
- " entry: "
1586
- " %a = alloca [0 x i32], align 4 "
1587
- " %cmp4 = icmp sgt i32 %len, 0 "
1588
- " br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup "
1589
- " for.body.preheader: "
1590
- " br label %for.body "
1591
- " for.cond.cleanup.loopexit: "
1592
- " br label %for.cond.cleanup "
1593
- " for.cond.cleanup: "
1594
- " ret void "
1595
- " for.body: "
1596
- " %iv = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ] "
1597
- " %idxprom = zext i32 %iv to i64 "
1598
- " %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* %a, i64 0, \
1599
- i64 %idxprom "
1600
- " store i32 0, i32* %arrayidx, align 4 "
1601
- " %inc = add nuw nsw i32 %iv, 1 "
1602
- " %cmp = icmp slt i32 %inc, %len "
1603
- " br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit "
1604
- " } " ,
1605
- Err, C);
1606
-
1607
- ASSERT_TRUE (M && " Could not parse module?" );
1608
- ASSERT_TRUE (!verifyModule (*M) && " Must have been well formed!" );
1609
-
1610
- runWithSE (*M, " foo" , [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1611
- auto *ScevIV = SE.getSCEV (getInstructionByName (F, " iv" ));
1612
- const Loop *L = cast<SCEVAddRecExpr>(ScevIV)->getLoop ();
1613
-
1614
- const SCEV *ITC = SE.getConstantMaxTripCountFromArray (L);
1615
- EXPECT_FALSE (isa<SCEVCouldNotCompute>(ITC));
1616
- EXPECT_TRUE (isa<SCEVConstant>(ITC));
1617
- EXPECT_EQ (cast<SCEVConstant>(ITC)->getAPInt ().getSExtValue (), 1 );
1618
- });
1619
- }
1620
-
1621
- TEST_F (ScalarEvolutionsTest, ComputeMaxTripCountFromExtremArray) {
1622
- LLVMContext C;
1623
- SMDiagnostic Err;
1624
- std::unique_ptr<Module> M = parseAssemblyString (
1625
- " define void @foo(i32 signext %len) { "
1626
- " entry: "
1627
- " %a = alloca [4294967295 x i1], align 4 "
1628
- " %cmp4 = icmp sgt i32 %len, 0 "
1629
- " br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup "
1630
- " for.body.preheader: "
1631
- " br label %for.body "
1632
- " for.cond.cleanup.loopexit: "
1633
- " br label %for.cond.cleanup "
1634
- " for.cond.cleanup: "
1635
- " ret void "
1636
- " for.body: "
1637
- " %iv = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ] "
1638
- " %idxprom = zext i32 %iv to i64 "
1639
- " %arrayidx = getelementptr inbounds [4294967295 x i1], \
1640
- [4294967295 x i1]* %a, i64 0, i64 %idxprom "
1641
- " store i1 0, i1* %arrayidx, align 4 "
1642
- " %inc = add nuw nsw i32 %iv, 1 "
1643
- " %cmp = icmp slt i32 %inc, %len "
1644
- " br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit "
1645
- " } " ,
1646
- Err, C);
1647
-
1648
- ASSERT_TRUE (M && " Could not parse module?" );
1649
- ASSERT_TRUE (!verifyModule (*M) && " Must have been well formed!" );
1650
-
1651
- runWithSE (*M, " foo" , [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1652
- auto *ScevIV = SE.getSCEV (getInstructionByName (F, " iv" ));
1653
- const Loop *L = cast<SCEVAddRecExpr>(ScevIV)->getLoop ();
1654
-
1655
- const SCEV *ITC = SE.getConstantMaxTripCountFromArray (L);
1656
- EXPECT_TRUE (isa<SCEVCouldNotCompute>(ITC));
1657
- });
1658
- }
1659
-
1660
- TEST_F (ScalarEvolutionsTest, ComputeMaxTripCountFromArrayInBranch) {
1661
- LLVMContext C;
1662
- SMDiagnostic Err;
1663
- std::unique_ptr<Module> M = parseAssemblyString (
1664
- " define void @foo(i32 signext %len) { "
1665
- " entry: "
1666
- " %a = alloca [8 x i32], align 4 "
1667
- " br label %for.cond "
1668
- " for.cond: "
1669
- " %iv = phi i32 [ %inc, %for.inc ], [ 0, %entry ] "
1670
- " %cmp = icmp slt i32 %iv, %len "
1671
- " br i1 %cmp, label %for.body, label %for.cond.cleanup "
1672
- " for.cond.cleanup: "
1673
- " br label %for.end "
1674
- " for.body: "
1675
- " %cmp1 = icmp slt i32 %iv, 8 "
1676
- " br i1 %cmp1, label %if.then, label %if.end "
1677
- " if.then: "
1678
- " %idxprom = sext i32 %iv to i64 "
1679
- " %arrayidx = getelementptr inbounds [8 x i32], [8 x i32]* %a, i64 0, \
1680
- i64 %idxprom "
1681
- " store i32 0, i32* %arrayidx, align 4 "
1682
- " br label %if.end "
1683
- " if.end: "
1684
- " br label %for.inc "
1685
- " for.inc: "
1686
- " %inc = add nsw i32 %iv, 1 "
1687
- " br label %for.cond "
1688
- " for.end: "
1689
- " ret void "
1690
- " } " ,
1691
- Err, C);
1692
-
1693
- ASSERT_TRUE (M && " Could not parse module?" );
1694
- ASSERT_TRUE (!verifyModule (*M) && " Must have been well formed!" );
1695
-
1696
- runWithSE (*M, " foo" , [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1697
- auto *ScevIV = SE.getSCEV (getInstructionByName (F, " iv" ));
1698
- const Loop *L = cast<SCEVAddRecExpr>(ScevIV)->getLoop ();
1699
-
1700
- const SCEV *ITC = SE.getConstantMaxTripCountFromArray (L);
1701
- EXPECT_TRUE (isa<SCEVCouldNotCompute>(ITC));
1702
- });
1703
- }
1704
-
1705
- TEST_F (ScalarEvolutionsTest, ComputeMaxTripCountFromMultiDemArray) {
1706
- LLVMContext C;
1707
- SMDiagnostic Err;
1708
- std::unique_ptr<Module> M = parseAssemblyString (
1709
- " define void @foo(i32 signext %len) { "
1710
- " entry: "
1711
- " %a = alloca [3 x [5 x i32]], align 4 "
1712
- " br label %for.cond "
1713
- " for.cond: "
1714
- " %iv = phi i32 [ %inc, %for.inc ], [ 0, %entry ] "
1715
- " %cmp = icmp slt i32 %iv, %len "
1716
- " br i1 %cmp, label %for.body, label %for.cond.cleanup "
1717
- " for.cond.cleanup: "
1718
- " br label %for.end "
1719
- " for.body: "
1720
- " %arrayidx = getelementptr inbounds [3 x [5 x i32]], \
1721
- [3 x [5 x i32]]* %a, i64 0, i64 3 "
1722
- " %idxprom = sext i32 %iv to i64 "
1723
- " %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %arrayidx, \
1724
- i64 0, i64 %idxprom "
1725
- " store i32 0, i32* %arrayidx1, align 4"
1726
- " br label %for.inc "
1727
- " for.inc: "
1728
- " %inc = add nsw i32 %iv, 1 "
1729
- " br label %for.cond "
1730
- " for.end: "
1731
- " ret void "
1732
- " } " ,
1733
- Err, C);
1734
-
1735
- ASSERT_TRUE (M && " Could not parse module?" );
1736
- ASSERT_TRUE (!verifyModule (*M) && " Must have been well formed!" );
1737
-
1738
- runWithSE (*M, " foo" , [](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
1739
- auto *ScevIV = SE.getSCEV (getInstructionByName (F, " iv" ));
1740
- const Loop *L = cast<SCEVAddRecExpr>(ScevIV)->getLoop ();
1741
-
1742
- const SCEV *ITC = SE.getConstantMaxTripCountFromArray (L);
1743
- EXPECT_TRUE (isa<SCEVCouldNotCompute>(ITC));
1744
- });
1745
- }
1746
-
1747
1539
TEST_F (ScalarEvolutionsTest, CheckGetPowerOfTwo) {
1748
1540
Module M (" CheckGetPowerOfTwo" , Context);
1749
1541
FunctionType *FTy = FunctionType::get (Type::getVoidTy (Context), {}, false );
0 commit comments