mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
fix the quotient returned by sdivrem() for the case when LHS is negative and RHS is positive
based on a patch by Preston Briggs, with some modifications git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157231 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -171,6 +171,34 @@ TEST(APIntTest, i1) {
|
||||
EXPECT_EQ(zero, neg_one.srem(one));
|
||||
EXPECT_EQ(zero, neg_one.urem(one));
|
||||
EXPECT_EQ(zero, one.srem(neg_one));
|
||||
|
||||
// sdivrem
|
||||
{
|
||||
APInt q(8, 0);
|
||||
APInt r(8, 0);
|
||||
APInt one(8, 1);
|
||||
APInt two(8, 2);
|
||||
APInt nine(8, 9);
|
||||
APInt four(8, 4);
|
||||
|
||||
EXPECT_EQ(nine.srem(two), one);
|
||||
EXPECT_EQ(nine.srem(-two), one);
|
||||
EXPECT_EQ((-nine).srem(two), -one);
|
||||
EXPECT_EQ((-nine).srem(-two), -one);
|
||||
|
||||
APInt::sdivrem(nine, two, q, r);
|
||||
EXPECT_EQ(four, q);
|
||||
EXPECT_EQ(one, r);
|
||||
APInt::sdivrem(-nine, two, q, r);
|
||||
EXPECT_EQ(-four, q);
|
||||
EXPECT_EQ(-one, r);
|
||||
APInt::sdivrem(nine, -two, q, r);
|
||||
EXPECT_EQ(-four, q);
|
||||
EXPECT_EQ(one, r);
|
||||
APInt::sdivrem(-nine, -two, q, r);
|
||||
EXPECT_EQ(four, q);
|
||||
EXPECT_EQ(-one, r);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(APIntTest, fromString) {
|
||||
|
Reference in New Issue
Block a user