------- Comment #21 from rguenther at suse dot de 2009-11-30 10:10 ------- Subject: Re: Weird translation of DO loops
On Mon, 30 Nov 2009, tkoenig at gcc dot gnu dot org wrote: > ------- Comment #20 from tkoenig at gcc dot gnu dot org 2009-11-30 07:31 > ------- > Created an attachment (id=19182) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19182&action=view) > --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19182&action=view) > Patch that works for unrolling > > It also passes do_3.F90. > > I'll submit just in time for meeting the phase 4 deadline tonight (hopefully). If it works for unrolling it must be indeed better. Though: + /* Calculate SIGN (1,step) */ + + tmp = fold_build2 (RSHIFT_EXPR, type, step, + build_int_cst (type, + TYPE_PRECISION (type) - 1)); + + tmp = fold_build2 (MULT_EXPR, type, tmp, + build_int_cst (type, 2)); + + step_sign = fold_build2 (PLUS_EXPR, type, tmp, + fold_convert (type, integer_one_node)); the "sign" for unsigned steps is always 1, you don't seem to account for unsignedness? Note that I believe generating step_sign = fold_build3 (fold_build2 (LT_EXPR, boolean_type_node, step, build_int_cst (TREE_TYPE (step), 0)), build_int_cst (type, -1), build_int_cst (type, 1)); is better as that allows more freedom for fold and efficient expansion for the target. Just double-check that it also works for the unrolling ;) Thanks, Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42131