From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26484 invoked by alias); 30 Nov 2009 10:10:36 -0000 Received: (qmail 26004 invoked by alias); 30 Nov 2009 10:10:18 -0000 Date: Mon, 30 Nov 2009 10:10:00 -0000 Message-ID: <20091130101018.26003.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/42131] Weird translation of DO loops In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenther at suse dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-11/txt/msg02584.txt.bz2 ------- 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