Commit 5eebe2eb by Richard Kenner

(synth_mult): Don't try to make recursive call if we would be shifting by a negative number.

(synth_mult): Don't try to make recursive call if we would be shifting
by a negative number.
(expand_mult): Don't negate VAL if it is negative.

From-SVN: r3788
parent fb5c8ce6
...@@ -1920,6 +1920,8 @@ synth_mult (t, cost_limit) ...@@ -1920,6 +1920,8 @@ synth_mult (t, cost_limit)
q = t - 1; q = t - 1;
q = q & -q; q = q & -q;
m = exact_log2 (q); m = exact_log2 (q);
if (m >= 0)
{
cost = shiftadd_cost[m]; cost = shiftadd_cost[m];
*alg_in = synth_mult ((t - 1) >> m, cost_limit - cost); *alg_in = synth_mult ((t - 1) >> m, cost_limit - cost);
...@@ -1932,10 +1934,13 @@ synth_mult (t, cost_limit) ...@@ -1932,10 +1934,13 @@ synth_mult (t, cost_limit)
best_alg->op[best_alg->ops++] = alg_add_t2_m; best_alg->op[best_alg->ops++] = alg_add_t2_m;
best_alg->cost = cost_limit = cost; best_alg->cost = cost_limit = cost;
} }
}
q = t + 1; q = t + 1;
q = q & -q; q = q & -q;
m = exact_log2 (q); m = exact_log2 (q);
if (m >= 0)
{
cost = shiftsub_cost[m]; cost = shiftsub_cost[m];
*alg_in = synth_mult ((t + 1) >> m, cost_limit - cost); *alg_in = synth_mult ((t + 1) >> m, cost_limit - cost);
...@@ -1949,6 +1954,7 @@ synth_mult (t, cost_limit) ...@@ -1949,6 +1954,7 @@ synth_mult (t, cost_limit)
best_alg->cost = cost_limit = cost; best_alg->cost = cost_limit = cost;
} }
} }
}
/* Now, use the simple method of adding or subtracting at the leftmost /* Now, use the simple method of adding or subtracting at the leftmost
1-bit. */ 1-bit. */
...@@ -2064,7 +2070,7 @@ expand_mult (mode, op0, op1, target, unsignedp) ...@@ -2064,7 +2070,7 @@ expand_mult (mode, op0, op1, target, unsignedp)
- negate_cost); - negate_cost);
if (neg_alg.cost + negate_cost < alg.cost) if (neg_alg.cost + negate_cost < alg.cost)
alg = neg_alg, negate = 1, val = - val; alg = neg_alg, negate = 1;
if (alg.cost < mult_cost) if (alg.cost < mult_cost)
{ {
......
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