public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/57262] New: Optimize bound intrinsics with dim=var for rank one arrays
@ 2013-05-13 9:44 burnus at gcc dot gnu.org
2013-05-13 12:02 ` [Bug fortran/57262] " dominiq at lps dot ens.fr
2013-05-13 12:38 ` burnus at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-05-13 9:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57262
Bug ID: 57262
Summary: Optimize bound intrinsics with dim=var for rank one
arrays
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: minor
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
I am not really sure whether this really occurs in real-world code, but I
realized that for rank=1 arrays, the following can be compile-time simplified.
! { dg-options "-fdump-tree-original" }
integer function foo(i)
implicit none
integer :: i, a(10)
foo = lbound (a, dim=i) + 2*ubound(a,dim=i) + 3*size(a,dim=i)
end
! { dg-final { scan-tree-dump "__result_bar = 51;" "original" } }
!
! * * *
!
! For the tree version, one could also replace the dim=i by dim=1:
integer function bar(jjj,n)
implicit none
integer :: jjj, n, a(n:)
bar = lbound (a, dim=jjj) + 2*ubound(a,dim=jjj) + 3*size(a,dim=jjj)
end
! { dg-final { scan-tree-dump-not "jjj" "original" } }
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/57262] Optimize bound intrinsics with dim=var for rank one arrays
2013-05-13 9:44 [Bug fortran/57262] New: Optimize bound intrinsics with dim=var for rank one arrays burnus at gcc dot gnu.org
@ 2013-05-13 12:02 ` dominiq at lps dot ens.fr
2013-05-13 12:38 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-05-13 12:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57262
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
What is expected if i (jjj) /= 1?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/57262] Optimize bound intrinsics with dim=var for rank one arrays
2013-05-13 9:44 [Bug fortran/57262] New: Optimize bound intrinsics with dim=var for rank one arrays burnus at gcc dot gnu.org
2013-05-13 12:02 ` [Bug fortran/57262] " dominiq at lps dot ens.fr
@ 2013-05-13 12:38 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-05-13 12:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57262
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Created attachment 30105
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30105&action=edit
Draft patch (trans-intrinsic.c only, ubound/lbound only, untested)
PATCH: Draft patch for the second case (i.e. after the bound check) - only
handles LBOUND/UBOUND. For SIZE, it only matters with inlining (which is done
on the Fortran-dev branch); thus, this part is left out.
TODO: Testing, test case and simplify.c handling.
(In reply to Dominique d'Humieres from comment #1)
> What is expected if i (jjj) /= 1?
Well, the whole bug is only for rank == 1 array!
Thus, using, e.g., jjj == 2 will be invalid (according to the Fortran standard)
and will access invalid memory. With my (untested!) attached patch, jjj=2
should still give a run-time error for -fcheck=all. (And without, it accesses
the bounds for dim=1 instead of invalid memory.)
For the first test case (patch to be written), you will loose the run-time
bounds check. Sorry!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-13 12:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-13 9:44 [Bug fortran/57262] New: Optimize bound intrinsics with dim=var for rank one arrays burnus at gcc dot gnu.org
2013-05-13 12:02 ` [Bug fortran/57262] " dominiq at lps dot ens.fr
2013-05-13 12:38 ` burnus at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).