From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31650 invoked by alias); 22 Jun 2010 14:42:58 -0000 Received: (qmail 31170 invoked by uid 48); 22 Jun 2010 14:42:35 -0000 Date: Tue, 22 Jun 2010 14:42:00 -0000 Message-ID: <20100622144235.31169.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/41137] inefficient zeroing of an array In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" 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: 2010-06/txt/msg02202.txt.bz2 ------- Comment #12 from burnus at gcc dot gnu dot org 2010-06-22 14:42 ------- (In reply to comment #11) > What's the reason why gfc_trans_zero_assign insists that len is INTEGER_CST? > At least if it is contiguous (and not assumed size), why can't memset be used > even for non-constant sizes? Suggested by Jakub: - if (!len || TREE_CODE (len) != INTEGER_CST) + if (!len + || (TREE_CODE (len) != INTEGER_CST + && !gfc_is_simply_contiguous (expr, false))) Though, one needs to be careful that one zeros the right spot (maybe already taken care of): a(5:) = 0 Additionally, one could do the same for arrays which are contiguous but have a descriptor - for which one has to calculate the size manually (as "len" == NULL). At least after memset/memcpy middle-end fixes, the change should be profitable. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41137