[PATCH] Fix IVOPTs induction variable choice for &a[0] and &a[4]
Richard Guenther
rguenther@suse.de
Fri Aug 1 14:57:00 GMT 2008
This fixes IVOPTs which was choosing two induction variables for uses
based on &a[0] and &a[4]. For the use based on &a[4] we add the bases
&a[4], 0 and (T *)&a as candidates while for &a[0] we only add the
bases &a[0] and 0. So we end up choosing two different induction
variables. (This happens in SPEC2k6 calculix in the hottest loop)
The following fixes this by adding a candidate also if the base
object differs after stripping constant offsets.
Bootstrap & regtest running on x86_64-unknown-linux-gnu, I'll apply
this to the trunk if that succeeds.
Richard.
2008-08-01 Richard Guenther <rguenther@suse.de>
* tree-ssa-loop-ivopts.c (add_iv_value_candidates): Also add
the candidate with the stripped base if that base is different
from the original base even for offset zero.
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
*** gcc/tree-ssa-loop-ivopts.c (revision 138521)
--- gcc/tree-ssa-loop-ivopts.c (working copy)
*************** add_iv_value_candidates (struct ivopts_d
*** 2275,2283 ****
add_candidate (data, build_int_cst (basetype, 0),
iv->step, true, use);
! /* Third, try removing the constant offset. */
base = strip_offset (iv->base, &offset);
! if (offset)
add_candidate (data, base, iv->step, false, use);
}
--- 2275,2285 ----
add_candidate (data, build_int_cst (basetype, 0),
iv->step, true, use);
! /* Third, try removing the constant offset. Make sure to even
! add a candidate for &a[0] vs. (T *)&a. */
base = strip_offset (iv->base, &offset);
! if (offset
! || base != iv->base)
add_candidate (data, base, iv->step, false, use);
}
More information about the Gcc-patches
mailing list