This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31593] Invariant DO loop variables and subroutines
- From: "tobi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Aug 2009 21:44:45 -0000
- Subject: [Bug fortran/31593] Invariant DO loop variables and subroutines
- References: <bug-31593-10391@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #21 from tobi at gcc dot gnu dot org 2009-08-14 21:44 -------
(In reply to comment #19)
> (In reply to comment #17)
> From quickly looking at the code, the copy to real_to is probably unnecessary
> because loop bounds are passed through gfc_evaluate_now before calling
> gfc_trans_simple_do ( never mind if it gives the good assembly :) ).
I suspected that this reason wouldn't hold. Place a wrong statement on the
internet, you will no after a few seconds :) The real reason is that no
pointer to the upper bound that is compared against can escape, so that better
assembler will result. I will update the comment.
> Couldn't the same be made in gfc_trans_do ?
There, the number of iterations is calculated before the loop, so the problem
doesn't arise. I'm guessing that before my patch, gfc_trans_simple_do actually
lead to a net slowdown of the generated code. Lesson learnt: don't optimize
without measuring or at least looking at the generated code :)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31593