From 52786026fabb4b32e7232eafe1dfb78afba5443b Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 2 Feb 1994 13:24:14 -0500 Subject: [PATCH] (synth_mult): Delay allocation of algorithm structures until they are needed. (synth_mult): Delay allocation of algorithm structures until they are needed. Reorder early-exit tests to avoid comparing value that is not yet set. From-SVN: r6464 --- gcc/expmed.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gcc/expmed.c b/gcc/expmed.c index 76c8a87c0cf..09e51adf23d 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -1,6 +1,6 @@ /* Medium-level subroutines: convert bit-field store and extract and shifts, multiplies and divides to rtl instructions. - Copyright (C) 1987, 1988, 1989, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc. This file is part of GNU CC. @@ -1851,10 +1851,7 @@ synth_mult (alg_out, t, cost_limit) int cost_limit; { int m; - struct algorithm *best_alg - = (struct algorithm *)alloca (sizeof (struct algorithm)); - struct algorithm *alg_in - = (struct algorithm *)alloca (sizeof (struct algorithm)); + struct algorithm *alg_in, *best_alg; unsigned int cost; unsigned HOST_WIDE_INT q; @@ -1889,6 +1886,11 @@ synth_mult (alg_out, t, cost_limit) } } + /* We'll be needing a couple extra algorithm structures now. */ + + alg_in = (struct algorithm *)alloca (sizeof (struct algorithm)); + best_alg = (struct algorithm *)alloca (sizeof (struct algorithm)); + /* If we have a group of zero bits at the low-order part of T, try multiplying by the remaining bits and then doing a shift. */ @@ -2051,16 +2053,16 @@ synth_mult (alg_out, t, cost_limit) } } - /* If we are getting a too long sequence for `struct algorithm' - to record, make this search fail. */ - if (best_alg->ops == MAX_BITS_PER_WORD) - return; - /* If cost_limit has not decreased since we stored it in alg_out->cost, we have not found any algorithm. */ if (cost_limit == alg_out->cost) return; + /* If we are getting a too long sequence for `struct algorithm' + to record, make this search fail. */ + if (best_alg->ops == MAX_BITS_PER_WORD) + return; + /* Copy the algorithm from temporary space to the space at alg_out. We avoid using structure assignment because the majority of best_alg is normally undefined, and this is a critical function. */ -- 2.30.2