static slsr_cand_t
lookup_cand (cand_idx idx)
{
- return cand_vec[idx - 1];
+ return cand_vec[idx];
}
/* Helper for hashing a candidate chain header. */
c->cand_type = ctype;
c->stride_type = stype;
c->kind = kind;
- c->cand_num = cand_vec.length () + 1;
+ c->cand_num = cand_vec.length ();
c->next_interp = 0;
c->first_interp = c->cand_num;
c->dependent = 0;
return base_cand->index;
}
- if (base_cand->next_interp)
- base_cand = lookup_cand (base_cand->next_interp);
- else
- base_cand = NULL;
+ base_cand = lookup_cand (base_cand->next_interp);
}
return 0;
+ stmt_cost (base_cand->cand_stmt, speed));
}
- if (base_cand->next_interp)
- base_cand = lookup_cand (base_cand->next_interp);
- else
- base_cand = NULL;
+ base_cand = lookup_cand (base_cand->next_interp);
}
if (!base)
+ stmt_cost (base_cand->cand_stmt, speed));
}
- if (base_cand->next_interp)
- base_cand = lookup_cand (base_cand->next_interp);
- else
- base_cand = NULL;
+ base_cand = lookup_cand (base_cand->next_interp);
}
if (!base)
+ stmt_cost (addend_cand->cand_stmt, speed));
}
- if (addend_cand->next_interp)
- addend_cand = lookup_cand (addend_cand->next_interp);
- else
- addend_cand = NULL;
+ addend_cand = lookup_cand (addend_cand->next_interp);
}
while (base_cand && !base && base_cand->kind != CAND_PHI)
savings = (subtrahend_cand->dead_savings
+ stmt_cost (subtrahend_cand->cand_stmt, speed));
}
-
- if (subtrahend_cand->next_interp)
- subtrahend_cand = lookup_cand (subtrahend_cand->next_interp);
- else
- subtrahend_cand = NULL;
+
+ subtrahend_cand = lookup_cand (subtrahend_cand->next_interp);
}
}
- if (base_cand->next_interp)
- base_cand = lookup_cand (base_cand->next_interp);
- else
- base_cand = NULL;
+ base_cand = lookup_cand (base_cand->next_interp);
}
if (!base)
+ stmt_cost (base_cand->cand_stmt, speed));
}
- if (base_cand->next_interp)
- base_cand = lookup_cand (base_cand->next_interp);
- else
- base_cand = NULL;
+ base_cand = lookup_cand (base_cand->next_interp);
}
if (!base)
if (first_cand != c)
c->first_interp = first_cand->cand_num;
- if (base_cand->next_interp)
- base_cand = lookup_cand (base_cand->next_interp);
- else
- base_cand = NULL;
+ base_cand = lookup_cand (base_cand->next_interp);
}
}
else
if (first_cand != c)
c->first_interp = first_cand->cand_num;
- if (base_cand->next_interp)
- base_cand = lookup_cand (base_cand->next_interp);
- else
- base_cand = NULL;
+ base_cand = lookup_cand (base_cand->next_interp);
}
}
else
fprintf (dump_file, "\nStrength reduction candidate vector:\n\n");
FOR_EACH_VEC_ELT (cand_vec, i, c)
- dump_candidate (c);
+ if (c != NULL)
+ dump_candidate (c);
}
/* Callback used to dump the candidate chains hash table. */
while (cc)
{
cc->cand_stmt = copy_stmt;
- cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
+ cc = lookup_cand (cc->next_interp);
}
if (dump_file && (dump_flags & TDF_DETAILS))
stmt_to_print = copy_stmt;
while (cc)
{
cc->cand_stmt = gsi_stmt (gsi);
- cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
+ cc = lookup_cand (cc->next_interp);
}
if (dump_file && (dump_flags & TDF_DETAILS))
stmt_to_print = gsi_stmt (gsi);
while (cc)
{
cc->cand_stmt = gsi_stmt (gsi);
- cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
+ cc = lookup_cand (cc->next_interp);
}
if (dump_file && (dump_flags & TDF_DETAILS))
while (cc)
{
cc->cand_stmt = gsi_stmt (gsi);
- cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
+ cc = lookup_cand (cc->next_interp);
}
if (dump_file && (dump_flags & TDF_DETAILS))
while (cc)
{
cc->cand_stmt = copy_stmt;
- cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
+ cc = lookup_cand (cc->next_interp);
}
if (dump_file && (dump_flags & TDF_DETAILS))
while (cc)
{
cc->cand_stmt = cast_stmt;
- cc = cc->next_interp ? lookup_cand (cc->next_interp) : NULL;
+ cc = lookup_cand (cc->next_interp);
}
if (dump_file && (dump_flags & TDF_DETAILS))
/* Each candidate that has a null basis and a non-null
dependent is the root of a tree of related statements.
Analyze each tree to determine a subset of those
- statements that can be replaced with maximum benefit. */
- FOR_EACH_VEC_ELT (cand_vec, i, c)
+ statements that can be replaced with maximum benefit.
+
+ Note the first NULL element is skipped. */
+ FOR_EACH_VEC_ELT_FROM (cand_vec, i, c, 1)
{
slsr_cand_t first_dep;
/* Create the obstack where candidates will reside. */
gcc_obstack_init (&cand_obstack);
- /* Allocate the candidate vector. */
+ /* Allocate the candidate vector and initialize the first NULL element. */
cand_vec.create (128);
+ cand_vec.safe_push (NULL);
/* Allocate the mapping from statements to candidate indices. */
stmt_cand_map = new hash_map<gimple *, slsr_cand_t>;