Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

GCC increment Optimization

Name: Anonymous 2009-05-28 17:25

Does anyone know if GCC v4.x optimizes automatically the incr i++; to ++i; ?

Name: Anonymous 2009-05-28 17:28

Maybe.

Name: Anonymous 2009-05-28 17:30

Perhaps.

Name: Anonymous 2009-05-28 17:31

PROTIP: Only when the previous value of i isn't needed.

Name: Anonymous 2009-05-28 17:43

"PROTIP: Only when the previous value of i isn't needed. "

obviously

Name: Anonymous 2009-05-28 17:44

GCC? [m]Optimizing[m]? In what Bizarro universe are you living in? GNU Can't Compile can't optimize worth shit.

Name: Anonymous 2009-05-28 17:45

Use JAVA

Name: Anonymous 2009-05-28 18:05

it doesn't fucking matter!

fuck all of you!

Name: Anonymous 2009-05-28 18:14

Yes.

% cat a.c
int main(void)
{
    int i;
    for(i = 0; i < 10; ++i)
    {
        puts("GRUNNUR");
    }
    return 0;
}
% cat b.c
int main(void)
{
    int i;
    for(i = 0; i < 10; i++)
    {
        puts("GRUNNUR");
    }
    return 0;
}
% gcc -S a.c; gcc -S b.c
% diff a.s b.s
1c1
<     .file    "a.c"
---
    .file    "b.c"
%  gcc --version
gcc (Gentoo 4.3.3-r2 p1.1, pie-10.1.5) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

%

Name: Anonymous 2009-05-28 18:21

>>8
expected help
4chan
didn't read >>5
I lol'd

Name: Anonymous 2009-05-28 18:45

% gcc -O1 -S a.c; gcc -S b.c
% diff a.s b.s
9,10d8
<       pushl   %edi
<       pushl   %esi
12,13c10,11
<       subl    $28, %esp
<       call    L7
---
      subl    $36, %esp
      call    L6
15c13
< L7:
---
L6:
17,20c15,19
<       movl    $10, %esi
<       leal    LC0-"L00000000001$pb"(%ebx), %edi
< L2:
<       movl    %edi, (%esp)
---
      movl    $0, -12(%ebp)
      jmp     L2
L3:
      leal    LC0-"L00000000001$pb"(%ebx), %eax
      movl    %eax, (%esp)
22,23c21,25
<       decl    %esi
<       jne     L2
---
      leal    -12(%ebp), %eax
      incl    (%eax)
L2:
      cmpl    $9, -12(%ebp)
      jle     L3
25c27
<       addl    $28, %esp
---
      addl    $36, %esp
27,28d28
<       popl    %esi
<       popl    %edi
% gcc --version
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

%

Name: Anonymous 2009-05-28 18:56

>>11
gcc -O1 -S a.c; gcc -S b.c

Name: Anonymous 2009-05-28 19:09

>>1
My eyes hurt.  Use diff -u next time.

Name: Anonymous 2009-05-28 20:29

>>1
You can‘t ''optimize´´ one to the other⁏ they‘re the same statement.

Name: Anonymous 2009-05-28 21:37

>>14
Sepples begs to differ.

Name: Anonymous 2009-05-28 22:55

>>15
My anus begs to differ.

Name: Anonymous 2009-05-28 22:58

>>16
What about you're anus?

Name: Anonymous 2009-05-29 6:09

Optimization in C?

Name: Anonymous 2009-05-29 8:45

>>18
Cptimsation

Name: Anonymous 2009-05-29 16:44

They are not the same, even when used as an expression-instruction:

++i; increments the value of i first and then puts it on the stack, to be immediately after cleared out (since the value isn't used)
i++; first puts 'i' on the stack, duplicates it, increments one 'i' and puts it back to 'i', leaving the unchanged value on the stack to be used if needed (cleared out after, as it isn't used)

to summarize, 'i++' uses one duplicate more than '++i'

Name: Anonymous 2009-05-29 16:55

>>20
wrong. you're a fucking moron that doesn't understand shit.
You're talking about the observations in a specific implementaiton under specific architecture models with a shitty compiler anyway. You assume a stack too -- C doesn't even need a stack. go fuck yourself, fucking C n00bs I hate them.

Name: Anonymous 2009-05-29 16:58

++i Considered Trolling

Name: Anonymous 2009-05-29 17:06

>>22
++i considered the default way of incrementing a variable. K&R uses it throughout.

Name: Anonymous 2009-05-29 17:25

>>19
(C)ptimisation

Name: Anonymous 2009-05-29 18:41

>>21
Is it really necessary to be so nasty?
I just don't think we should be the type of community to belittle others like that. This isn't /b/, this is /prog/. Show some manners, please :-)

Name: Anonymous 2009-05-29 18:48

>>25
I think you mean «Use more kindness!».

Name: Anonymous 2009-05-29 19:26

OP should use Sun Studio

Name: Anonymous 2009-05-29 19:33

>>26
Stop using «extra«-«faggot» «quotes»!!

Name: Anonymous 2009-05-29 20:01

>>28
You wouldn't know <<extra>>-<<faggot>>-<<quotes>> if they bit you on the ass!!

Name: Anonymous 2009-05-30 4:46

>>24
©ptimisation

Name: Anonymous 2009-05-30 5:24

>>30
I see what you did there, FrozenVoid.

Name: Anonymous 2009-05-30 5:46

>>6
You are not only wrong, you are also not an EXPERT BBCODE PROGRAMMER.

Atone by reading SICP and chanting our lord Sussman's psalm ``We conjure the spirits of the computer with our spells''

Name: Anonymous 2009-05-30 9:58

>>32
That will sound awfully strange. "Faggot quotes we conjure the spirits of the computer with our spells end faggot quotes."

Doesn't really have a nice ring to it.

Name: Anonymous 2009-05-30 10:19

``HELL YEAH''

Name: Anonymous 2009-05-30 14:45

66HELL YEAH99

Name: Anonymous 2009-05-30 17:50

Knuth's Law: As a /prog/ discussion grows longer, the probability of ``faggot quote trolls'' approaches 1.

Name: Anonymous 2009-05-30 17:54

>>35-36
As a /prog/ thread grows longer, the probability of Sagefault approaches e^phi.

Name: Anonymous 2009-05-30 17:59

>>37
This post didn't use TeX.

Name: Anonymous 2009-05-30 18:02

RMS Matthew Stallman's Law: As a /prog/ discussion grows longer, the probability of recursive acronym trolls approaches 1.

Name: Anonymous 2009-05-30 18:07

>>39
What do their posts look like?  Complaining about the recursive acronyms?  I think I've only seen that once or twice.

Name: Anonymous 2009-05-30 18:10

>>40
They pick innocent acronyms and create self-referencing expansions for them.

Name: Anonymous 2009-05-30 18:15

>>41
But that was done in >>39!  I see, a recursive troll!  They got me there!!

Name: Anonymous 2009-05-30 18:29

>>42
>>43 is another recursive troll, just read his post!

Name: Anonymous 2009-05-30 18:29

>>42
I would say that was a reflective troll rather than a recursive one.

Name: Anonymous 2009-05-30 19:57

Fuck Yeah Reflective Trolling

Name: Anonymous 2011-02-04 17:23


Don't change these.
Name: Email:
Entire Thread Thread List