From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1792 invoked by alias); 1 Mar 2007 18:55:05 -0000 Received: (qmail 1700 invoked by uid 48); 1 Mar 2007 18:54:55 -0000 Date: Thu, 01 Mar 2007 18:55:00 -0000 Subject: [Bug fortran/31016] New: Use __buildin_memcpy and __memcpy for array assignment X-Bugzilla-Reason: CC Message-ID: 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: 2007-03/txt/msg00050.txt.bz2 For the most common array assignments where the size is known at compile-time, we already use __buildin_memcpy; but the following cases were missed: subroutine bar(a) implicit none real :: a(*),b(12) b = a(1:12) end subroutine subroutine bar(a,b) implicit none real :: a(*),b(*) a(1:12) = b(2:13) end subroutine And __buildin_memset can be used for: subroutine bar(a) implicit none real :: a(*),b(12) a(1:12) = 12 end subroutine For the following examples, the __buildin_* function can not be used as the size is not known at compile time, but the memory should be contiguous and thus __memcpy can be used: subroutine bar(a,n) implicit none integer :: n real :: a(n), b(n) a = b end subroutine For the following case, one could use memset, but I'm not sure whether it will be on average be faster than a normal do loop. (Overhead of function call versus the optimization of memset using e.g. copy-on-write.) subroutine bar(a,n) implicit none integer :: n real :: a(n) a = 5 end subroutine -- Summary: Use __buildin_memcpy and __memcpy for array assignment Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31016