Commit 142d8164 authored by Matthias Braun's avatar Matthias Braun
Browse files

use tarval_shX_unsigned where possible

parent 1994b51f
......@@ -65,12 +65,10 @@ static ir_tarval *create_lsb_mask(ir_tarval *tv)
/* Creates a bit mask that have the msb and all less significant bits set. */
static ir_tarval *create_msb_mask(ir_tarval *tv)
{
ir_mode *mode = get_tarval_mode(tv);
ir_tarval *shift_amount = get_tarval_one(mode);
unsigned shift_amount = 1;
for (int msb = get_tarval_highest_bit(tv); msb != 0; msb /= 2) {
tv = tarval_or(tv, tarval_shr(tv, shift_amount));
shift_amount = tarval_add(shift_amount, shift_amount);
tv = tarval_or(tv, tarval_shr_unsigned(tv, shift_amount));
shift_amount *= 2;
}
return tv;
......@@ -132,9 +130,8 @@ static void dca_transfer(ir_node *irn, pdeq *q)
* don't fit into the smaller mode. */
if (get_tarval_highest_bit(care) >= (int)pred_bits)
care = tarval_or(care,
tarval_shl(get_tarval_one(mode),
new_tarval_from_long(
pred_bits - 1, mode)));
tarval_shl_unsigned(get_tarval_one(mode),
pred_bits - 1));
} else {
/* Thwart sign extension as it doesn't make sense on
* our abstract tarvals. */
......@@ -249,12 +246,9 @@ static void dca_transfer(ir_node *irn, pdeq *q)
if (is_Const(right))
care_for(
left,
tarval_shr(
care_mask,
new_tarval_from_long(
get_tarval_lowest_bit(
get_Const_tarval(right)), mode)),
q);
tarval_shr_unsigned(care_mask,
get_tarval_lowest_bit(
get_Const_tarval(right))), q);
else
care_for(left, care_mask, q);
......
......@@ -269,10 +269,8 @@ static ir_tarval *condensed_to_value(mul_env *env, unsigned char *R, int r)
ir_tarval *res = NULL;
for (int i = 0; i < r; ++i) {
int j = R[i];
if (j) {
ir_tarval *t = new_tarval_from_long(j, mode_Iu);
tv = tarval_shl(tv, t);
}
if (j)
tv = tarval_shl_unsigned(tv, j);
res = res ? tarval_add(res, tv) : tv;
}
return res;
......@@ -626,8 +624,8 @@ static int tv_ld2(ir_tarval *tv, int bits)
#define ABS(a) tarval_abs(a)
#define NEG(a) tarval_neg(a)
#define NOT(a) tarval_not(a)
#define SHL(a, b) tarval_shl(a, b)
#define SHR(a, b) tarval_shr(a, b)
#define SHL(a, b) tarval_shl_unsigned(a, b)
#define SHR(a, b) tarval_shr_unsigned(a, b)
#define ADD(a, b) tarval_add(a, b)
#define SUB(a, b) tarval_sub(a, b, NULL)
#define MUL(a, b) tarval_mul(a, b)
......@@ -661,7 +659,7 @@ static struct ms magic(ir_tarval *d)
ir_tarval *ad, *anc, *delta, *q1, *r1, *q2, *r2, *t; /* unsigned */
ir_relation d_cmp, M_cmp;
ir_tarval *bits_minus_1, *two_bits_1;
ir_tarval *two_bits_1;
struct ms mag;
......@@ -671,11 +669,10 @@ static struct ms magic(ir_tarval *d)
tarval_set_integer_overflow_mode(TV_OVERFLOW_WRAP);
/* 2^(bits-1) */
bits_minus_1 = new_tarval_from_long(bits - 1, u_mode);
two_bits_1 = SHL(get_mode_one(u_mode), bits_minus_1);
two_bits_1 = SHL(get_mode_one(u_mode), bits-1);
ad = CNV(ABS(d), u_mode);
t = ADD(two_bits_1, SHR(CNV(d, u_mode), bits_minus_1));
t = ADD(two_bits_1, SHR(CNV(d, u_mode), bits-1));
anc = SUB(SUB(t, ONE(u_mode)), MOD(t, ad)); /* Absolute value of nc */
p = bits - 1; /* Init: p */
q1 = DIV(two_bits_1, anc); /* Init: q1 = 2^p/|nc| */
......@@ -757,7 +754,7 @@ static struct magicu_info compute_unsigned_magic_info(ir_tarval *divisor, unsign
const unsigned extra_shift = UINT_BITS - num_bits;
/* The initial power of 2 is one less than the first one that can possibly work */
ir_tarval *initial_power_of_2 = SHL(ONE(mode), new_tarval_from_long(UINT_BITS - 1, mode));
ir_tarval *initial_power_of_2 = SHL(ONE(mode), UINT_BITS - 1);
/* The remainder and quotient of our power of 2 divided by divisor */
ir_tarval *quotient = DIV(initial_power_of_2, divisor);
......@@ -773,7 +770,7 @@ static struct magicu_info compute_unsigned_magic_info(ir_tarval *divisor, unsign
/* Compute ceil(log_2 D) */
ceil_log_2_D = 0;
for (ir_tarval *tmp = divisor; CMP(tmp, ZERO(mode)) & ir_relation_greater; tmp = SHR(tmp, ONE(mode)))
for (ir_tarval *tmp = divisor; CMP(tmp, ZERO(mode)) & ir_relation_greater; tmp = SHR(tmp, 1))
ceil_log_2_D++;
/* Begin a loop that increments the exponent, until we find a power of 2 that works. */
......@@ -796,12 +793,12 @@ static struct magicu_info compute_unsigned_magic_info(ir_tarval *divisor, unsign
* so the check for >= ceil_log_2_D is critical. */
if ((exponent + extra_shift >= ceil_log_2_D) ||
/* (divisor - remainder) <= (1 << exponent + extra_shift) */
(CMP(SUB(divisor, remainder), SHL(ONE(mode), new_tarval_from_long(exponent + extra_shift, mode))) & ir_relation_less_equal))
(CMP(SUB(divisor, remainder), SHL(ONE(mode), exponent + extra_shift)) & ir_relation_less_equal))
break;
/* Set magic_down if we have not set it yet and this exponent works for the round_down algorithm */
if (! has_magic_down &&
(CMP(remainder, SHL(ONE(mode), new_tarval_from_long(exponent + extra_shift, mode))) &
(CMP(remainder, SHL(ONE(mode), exponent + extra_shift)) &
ir_relation_less_equal)) {
has_magic_down = 1;
down_multiplier = quotient;
......@@ -827,7 +824,7 @@ static struct magicu_info compute_unsigned_magic_info(ir_tarval *divisor, unsign
unsigned pre_shift = 0;
ir_tarval *shifted_D = divisor;
while (CMP(AND(shifted_D, ONE(mode)), ZERO(mode)) & ir_relation_equal) {
shifted_D = SHR(shifted_D, ONE(mode));
shifted_D = SHR(shifted_D, 1);
pre_shift += 1;
}
result = compute_unsigned_magic_info(shifted_D, num_bits - pre_shift);
......
......@@ -5165,9 +5165,8 @@ static ir_node *transform_node_Shrs(ir_node *n)
/* normalisation: use Shr when sign bit is guaranteed to be cleared */
attr = vrp_get_info(a);
if (attr != NULL) {
unsigned bits = get_mode_size_bits(mode);
ir_tarval *scount = new_tarval_from_long(bits-1, mode_Iu);
ir_tarval *sign = tarval_shl(get_mode_one(mode), scount);
unsigned bits = get_mode_size_bits(mode);
ir_tarval *sign = tarval_shl_unsigned(get_mode_one(mode), bits-1);
if (tarval_is_null(tarval_and(attr->bits_not_set, sign))) {
dbg_info *dbgi = get_irn_dbg_info(n);
ir_node *block = get_nodes_block(n);
......
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