aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1993-03-19 17:30:21 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1993-03-19 17:30:21 -0500
commit5eebe2eb038f42c58ae6c3b55a474c79df7f5ce2 (patch)
treeb132049312bc01e9da9f56c883fb29c2b782d4cb
parentfb5c8ce64aa4c73336fe3abee7ff193cc85d5d73 (diff)
downloadgcc-5eebe2eb038f42c58ae6c3b55a474c79df7f5ce2.zip
gcc-5eebe2eb038f42c58ae6c3b55a474c79df7f5ce2.tar.gz
gcc-5eebe2eb038f42c58ae6c3b55a474c79df7f5ce2.tar.bz2
(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
-rw-r--r--gcc/expmed.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 87f4181..18a499f 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -1920,33 +1920,39 @@ synth_mult (t, cost_limit)
q = t - 1;
q = q & -q;
m = exact_log2 (q);
- cost = shiftadd_cost[m];
- *alg_in = synth_mult ((t - 1) >> m, cost_limit - cost);
-
- cost += alg_in->cost;
- if (cost < best_alg->cost)
+ if (m >= 0)
{
- struct algorithm *x;
- x = alg_in, alg_in = best_alg, best_alg = x;
- best_alg->log[best_alg->ops] = m;
- best_alg->op[best_alg->ops++] = alg_add_t2_m;
- best_alg->cost = cost_limit = cost;
+ cost = shiftadd_cost[m];
+ *alg_in = synth_mult ((t - 1) >> m, cost_limit - cost);
+
+ cost += alg_in->cost;
+ if (cost < best_alg->cost)
+ {
+ struct algorithm *x;
+ x = alg_in, alg_in = best_alg, best_alg = x;
+ best_alg->log[best_alg->ops] = m;
+ best_alg->op[best_alg->ops++] = alg_add_t2_m;
+ best_alg->cost = cost_limit = cost;
+ }
}
q = t + 1;
q = q & -q;
m = exact_log2 (q);
- cost = shiftsub_cost[m];
- *alg_in = synth_mult ((t + 1) >> m, cost_limit - cost);
-
- cost += alg_in->cost;
- if (cost < best_alg->cost)
+ if (m >= 0)
{
- struct algorithm *x;
- x = alg_in, alg_in = best_alg, best_alg = x;
- best_alg->log[best_alg->ops] = m;
- best_alg->op[best_alg->ops++] = alg_sub_t2_m;
- best_alg->cost = cost_limit = cost;
+ cost = shiftsub_cost[m];
+ *alg_in = synth_mult ((t + 1) >> m, cost_limit - cost);
+
+ cost += alg_in->cost;
+ if (cost < best_alg->cost)
+ {
+ struct algorithm *x;
+ x = alg_in, alg_in = best_alg, best_alg = x;
+ best_alg->log[best_alg->ops] = m;
+ best_alg->op[best_alg->ops++] = alg_sub_t2_m;
+ best_alg->cost = cost_limit = cost;
+ }
}
}
@@ -2064,7 +2070,7 @@ expand_mult (mode, op0, op1, target, unsignedp)
- negate_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)
{