llvm.org GIT mirror llvm / 32986d3
[ConstantRange] [a, b) udiv a full range is [0, umax(b)). Reviewers: nikic, spatel, efriedma Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D60536 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359180 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 5 months ago
2 changed file(s) with 10 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
973973 ConstantRange::udiv(const ConstantRange &RHS) const {
974974 if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax().isNullValue())
975975 return getEmpty();
976 if (RHS.isFullSet())
977 return getFull();
978976
979977 APInt Lower = getUnsignedMin().udiv(RHS.getUnsignedMax());
980978
820820 EXPECT_EQ(Some.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 0x111)));
821821 EXPECT_EQ(Some.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa)));
822822 EXPECT_EQ(Wrap.udiv(Wrap), Full);
823
824
825 ConstantRange Zero(APInt(16, 0));
826 EXPECT_EQ(Zero.udiv(One), Zero);
827 EXPECT_EQ(Zero.udiv(Full), Zero);
828
829 EXPECT_EQ(ConstantRange(APInt(16, 0), APInt(16, 99)).udiv(Full),
830 ConstantRange(APInt(16, 0), APInt(16, 99)));
831 EXPECT_EQ(ConstantRange(APInt(16, 10), APInt(16, 99)).udiv(Full),
832 ConstantRange(APInt(16, 0), APInt(16, 99)));
823833 }
824834
825835 TEST_F(ConstantRangeTest, URem) {