Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #1858

Re: Loop Invariance Optimization Opportunity?

From Shao Miller <sha0.miller@gmail.com>
Newsgroups comp.std.c
Subject Re: Loop Invariance Optimization Opportunity?
Date 2013-01-18 15:36 -0500
Organization A noiseless patient Spider
Message-ID <kdcbp7$5j6$1@dont-email.me> (permalink)
References <kdbifk$nhb$1@dont-email.me> <altersFe0nnU1@mid.individual.net>

Show all headers | View raw


On 1/18/2013 12:25, Wojtek Lerch wrote:
> On 18-Jan-13 8:25 AM, Shao Miller wrote:
>> GCC without an -O, with -O2, and with -O3 didn't make any difference in
>> the behaviour.  If an invariance optimization is used, the loop should
>> iterate 42 times, instead of 21.
>
> Have you tried you moving "looper" into a separate translation unit?
>
> I'm getting 42 with GCC 4.4.2, but 21 with GCC 4.6.3.

Aha!  Thank you for those measurements!  Just out of curiosity, were you 
using a >= C99 mode (where effective type is applicable)?

I had used -ansi and -std=c99 with GCC 4.5.3 for Cygwin, originally.

GCC 4.7.2 on Linux x86:

   gcc -ansi -pedantic -Wall -Wextra -Werror -o rvalue rvalue.c : 21

All combinations of -std=c99, -std=c1x, -std=c11, -O2, -O3 made no 
difference.

CLANG 3.0 on Linux x86:

   clang -ansi -pedantic -Wall -Wextra -Werror -o rvalue rvalue.c : 21

All combinations of -std=c99, -std=c1x, -O2, -O3 made no difference.

Copying the 'struct visible' definition into rvalue2.c and moving 
'looper' into it didn't change clang's behaviour.

   gcc -O2 -ansi -pedantic -Wall -Wextra -Werror -o rvalue rvalue.c 
rvalue2.c : 22 (?!)

Same with -O3.  Same with -std=c99, -std=c1x, -std=c11 or any of these 
with -O3.

I cannot reproduce 42. :(

-- 
- Shao Miller
--
"Thank you for the kind words; those are the kind of words I like to hear.

Cheerily,"  -- Richard Harter

Back to comp.std.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Loop Invariance Optimization Opportunity? Shao Miller <sha0.miller@gmail.com> - 2013-01-18 08:25 -0500
  Re: Loop Invariance Optimization Opportunity? Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-18 12:25 -0500
    Re: Loop Invariance Optimization Opportunity? Shao Miller <sha0.miller@gmail.com> - 2013-01-18 15:36 -0500
      Re: Loop Invariance Optimization Opportunity? Shao Miller <sha0.miller@gmail.com> - 2013-01-21 00:43 -0500

csiph-web