Commit 28c24f7a authored by Matthias Braun's avatar Matthias Braun
Browse files

Adapt unittests to tarval_sub mode parameter removal

parent 9b02a9db
...@@ -47,11 +47,6 @@ static void compare_tv(const char *file, unsigned line, ...@@ -47,11 +47,6 @@ static void compare_tv(const char *file, unsigned line,
typedef ir_tarval* (*binop)(ir_tarval *op0, ir_tarval *op1); typedef ir_tarval* (*binop)(ir_tarval *op0, ir_tarval *op1);
typedef ir_tarval* (*unop)(ir_tarval *op); typedef ir_tarval* (*unop)(ir_tarval *op);
static ir_tarval *simple_sub(ir_tarval *op0, ir_tarval *op1)
{
return tarval_sub(op0, op1, get_tarval_mode(op0));
}
/* tarval_div, except that x/0 == 0 */ /* tarval_div, except that x/0 == 0 */
static ir_tarval *safe_div(ir_tarval *op0, ir_tarval *op1) static ir_tarval *safe_div(ir_tarval *op0, ir_tarval *op1)
{ {
...@@ -288,7 +283,7 @@ static void test_int_tarvals(ir_mode *mode) ...@@ -288,7 +283,7 @@ static void test_int_tarvals(ir_mode *mode)
/* binops - neutral elements */ /* binops - neutral elements */
test_neutral(tarval_add, zero, true); test_neutral(tarval_add, zero, true);
test_neutral(simple_sub, zero, false); test_neutral(tarval_sub, zero, false);
test_neutral(tarval_mul, one, true); test_neutral(tarval_mul, one, true);
test_neutral(tarval_div, one, false); test_neutral(tarval_div, one, false);
/* tarval_mod has no neutral element */ /* tarval_mod has no neutral element */
...@@ -315,7 +310,7 @@ static void test_int_tarvals(ir_mode *mode) ...@@ -315,7 +310,7 @@ static void test_int_tarvals(ir_mode *mode)
/* binops - inverse elements */ /* binops - inverse elements */
test_inverse(tarval_add, tarval_neg, zero); test_inverse(tarval_add, tarval_neg, zero);
test_inverse(simple_sub, tarval_id, zero); test_inverse(tarval_sub, tarval_id, zero);
test_inverse(tarval_and, tarval_not, zero); test_inverse(tarval_and, tarval_not, zero);
test_inverse(tarval_andnot, tarval_id, zero); test_inverse(tarval_andnot, tarval_id, zero);
test_inverse(tarval_or, tarval_not, all_one); test_inverse(tarval_or, tarval_not, all_one);
...@@ -486,7 +481,7 @@ static void test_float_tarvals(ir_mode *mode) ...@@ -486,7 +481,7 @@ static void test_float_tarvals(ir_mode *mode)
/* binops - neutral elements */ /* binops - neutral elements */
test_neutral(tarval_add, minus_zero, true); test_neutral(tarval_add, minus_zero, true);
test_neutral(simple_sub, zero, false); test_neutral(tarval_sub, zero, false);
test_neutral(tarval_mul, one, true); test_neutral(tarval_mul, one, true);
test_neutral(tarval_div, one, false); test_neutral(tarval_div, one, false);
/* zero is a neutral element for tarval_add, except for the /* zero is a neutral element for tarval_add, except for the
...@@ -510,7 +505,7 @@ static void test_float_tarvals(ir_mode *mode) ...@@ -510,7 +505,7 @@ static void test_float_tarvals(ir_mode *mode)
TEST(tarval_is_quiet_nan(tarval_mul(value, zero))); TEST(tarval_is_quiet_nan(tarval_mul(value, zero)));
} else { } else {
TVS_EQUAL(tarval_mul(value, zero), tarval_is_negative(value) ? minus_zero : zero); TVS_EQUAL(tarval_mul(value, zero), tarval_is_negative(value) ? minus_zero : zero);
TVS_EQUAL(simple_sub(value, value), zero); TVS_EQUAL(tarval_sub(value, value), zero);
} }
} }
...@@ -523,7 +518,7 @@ static void test_float_tarvals(ir_mode *mode) ...@@ -523,7 +518,7 @@ static void test_float_tarvals(ir_mode *mode)
ir_tarval *nan = i == 0 ? qnan : snan; ir_tarval *nan = i == 0 ? qnan : snan;
test_binop_nan(tarval_add, nan); test_binop_nan(tarval_add, nan);
test_binop_nan(simple_sub, nan); test_binop_nan(tarval_sub, nan);
test_binop_nan(tarval_mul, nan); test_binop_nan(tarval_mul, nan);
test_binop_nan(tarval_div, nan); test_binop_nan(tarval_div, nan);
test_unop_nan(tarval_abs, nan); test_unop_nan(tarval_abs, nan);
...@@ -544,7 +539,7 @@ static void test_float_tarvals(ir_mode *mode) ...@@ -544,7 +539,7 @@ static void test_float_tarvals(ir_mode *mode)
TEST(tarval_is_quiet_nan(tarval_mul(minus_zero, minus_inf))); TEST(tarval_is_quiet_nan(tarval_mul(minus_zero, minus_inf)));
TEST(tarval_is_quiet_nan(tarval_add(minus_inf, inf))); TEST(tarval_is_quiet_nan(tarval_add(minus_inf, inf)));
TEST(tarval_is_quiet_nan(simple_sub(inf, inf))); TEST(tarval_is_quiet_nan(tarval_sub(inf, inf)));
/* infinity results */ /* infinity results */
for (unsigned i = 0, n = n_tarvals; i < n; ++i) { for (unsigned i = 0, n = n_tarvals; i < n; ++i) {
......
...@@ -43,7 +43,7 @@ int main(void) ...@@ -43,7 +43,7 @@ int main(void)
ir_tarval *one = new_tarval_from_long(1, big_s); ir_tarval *one = new_tarval_from_long(1, big_s);
ir_tarval *longmaxp = tarval_add(longmax, one); ir_tarval *longmaxp = tarval_add(longmax, one);
assert(!tarval_is_long(longmaxp)); assert(!tarval_is_long(longmaxp));
ir_tarval *longmax3 = tarval_sub(longmaxp, one, big_s); ir_tarval *longmax3 = tarval_sub(longmaxp, one);
assert(tarval_is_long(longmax3)); assert(tarval_is_long(longmax3));
ir_tarval *longmax2 = sizeof(long) == 8 ? get_mode_max(mode_Ls) ir_tarval *longmax2 = sizeof(long) == 8 ? get_mode_max(mode_Ls)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment