Re: Microsoft agrees with "hoisting loop invariants" by programmers!!! News @ 11
From: Corey Murtagh (emonk_at_slingshot.no.uce)
Date: 10/09/04
- Next message: CBFalconer: "Re: C++: Pointer to a string in a class"
- Previous message: Friedrich Dominicus: "Re: Some thoughts about OO programming"
- In reply to: Arthur J. O'Dwyer: "Re: Microsoft agrees with "hoisting loop invariants" by programmers!!! News @ 11"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 09 Oct 2004 18:02:33 +1300
Arthur J. O'Dwyer wrote:
>
> On Fri, 8 Oct 2004, Randy Howard wrote:
>
>>
>> <http://msdn.microsoft.com/library/default.asp?url=/library/en-
>> us/dnvc60/html/optcode.asp>
>>
>> Quoting from the article:
>>
>> Often, some code inside a loop, which is repeated many times, does
>> not change values during the loop's execution. These loop invariants
>> can be calculated once before the loop runs.
>>
>> Removing or hoisting loop invariants generally improves speed without
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> affecting size very much.
>
> Well, they're right, aren't they? I assume you're posting "hey,
> something vaguely amusing about Microsoft," but I can't tell whether
> you mean "hey, M$ finally figured out that invariant hoisting is a
> good thing!" or "hey, M$ is so dumb they think you need to hoist
> invariants in C++ code!" or perhaps something I'm missing.
I believe Randy is adding yet more evidence to the heap against eddie
who seems to believe that 'hoisting loop invariants' is a crime against
readability as well as needlessly premature optimisation that will be
performed by the compiler anyway.
> In any event, please note that in the rest of the article, Heller
> mentions that MSVC++6.0 does hoisting for you, so the C++ examples
> must be meant as a kind of pseudocode. I don't think the author
> expects people to hoist such trivial invariants in real C++ code
> that they're going to feed to an optimizing compiler anyway.
Where the optimiser is capable of doing so, sure. When the optimiser is
likely to choke on it you should of course help it along. This is
especially true of compilers with poor optimisation.
-- Corey Murtagh The Electric Monk "Quidquid latine dictum sit, altum videtur!"
- Next message: CBFalconer: "Re: C++: Pointer to a string in a class"
- Previous message: Friedrich Dominicus: "Re: Some thoughts about OO programming"
- In reply to: Arthur J. O'Dwyer: "Re: Microsoft agrees with "hoisting loop invariants" by programmers!!! News @ 11"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|