Skip to content

Commit a20544e

Browse files
committed
remove redundant test case
1 parent 59bab99 commit a20544e

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

llvm/unittests/ADT/APIntTest.cpp

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,34 +3050,6 @@ TEST(APIntTest, smul_ov) {
30503050
}
30513051

30523052
TEST(APIntTest, sfloordiv_ov) {
3053-
// test negative quotient
3054-
{
3055-
APInt divisor(32, -3, true);
3056-
APInt dividend(32, 2, true);
3057-
bool Overflow = false;
3058-
auto quotient = divisor.sfloordiv_ov(dividend, Overflow);
3059-
EXPECT_FALSE(Overflow);
3060-
EXPECT_EQ(-2, quotient.getSExtValue());
3061-
}
3062-
// test positive quotient
3063-
{
3064-
APInt divisor(32, 3, true);
3065-
APInt dividend(32, 2, true);
3066-
bool Overflow = false;
3067-
auto quotient = divisor.sfloordiv_ov(dividend, Overflow);
3068-
EXPECT_FALSE(Overflow);
3069-
EXPECT_EQ(1, quotient.getSExtValue());
3070-
}
3071-
// int8 test overflow
3072-
{
3073-
using IntTy = int8_t;
3074-
APInt divisor(8 * sizeof(IntTy), std::numeric_limits<IntTy>::lowest(),
3075-
true);
3076-
APInt dividend(8 * sizeof(IntTy), IntTy(-1), true);
3077-
bool Overflow = false;
3078-
(void)divisor.sfloordiv_ov(dividend, Overflow);
3079-
EXPECT_TRUE(Overflow);
3080-
}
30813053
// int16 test overflow
30823054
{
30833055
using IntTy = int16_t;
@@ -3110,24 +3082,30 @@ TEST(APIntTest, sfloordiv_ov) {
31103082
}
31113083
// test all of int8
31123084
{
3113-
bool Overflow = true;
3085+
bool Overflow = false;
31143086
for (int i = -128; i < 128; ++i) {
31153087
for (int j = -128; j < 128; ++j) {
3116-
if (j == 0 || (i == -128 && j == -1))
3088+
if (j == 0)
31173089
continue;
3090+
31183091
int8_t a = static_cast<int8_t>(i);
31193092
int8_t b = static_cast<int8_t>(j);
31203093

31213094
APInt divisor(8, a, true);
31223095
APInt dividend(8, b, true);
3096+
APInt quotient = divisor.sfloordiv_ov(dividend, Overflow);
3097+
3098+
if (i == -128 && j == -1) {
3099+
EXPECT_TRUE(Overflow);
3100+
continue;
3101+
}
3102+
31233103
if (((i >= 0 && j > 0) || (i <= 0 && j < 0)) ||
31243104
(i % j == 0)) // if quotient >= 0 and remain == 0 floordiv
31253105
// equivalent to div
3126-
EXPECT_EQ(divisor.sfloordiv_ov(dividend, Overflow).getSExtValue(),
3127-
a / b);
3106+
EXPECT_EQ(quotient.getSExtValue(), a / b);
31283107
else
3129-
EXPECT_EQ(divisor.sfloordiv_ov(dividend, Overflow).getSExtValue(),
3130-
a / b - 1);
3108+
EXPECT_EQ(quotient.getSExtValue(), a / b - 1);
31313109
EXPECT_FALSE(Overflow);
31323110
}
31333111
}

0 commit comments

Comments
 (0)