Re: C/C++ Compiler's Optimization Failed
From: Bryan Parkoff (bryan.nospam.parkoff_at_nospam.com)
Date: 02/21/04
- Next message: hutch--: "Re: C/C++ Compiler's Optimization Failed"
- Previous message: Jack Klein: "Re: C/C++ Compiler's Optimization Failed"
- In reply to: Jack Klein: "Re: C/C++ Compiler's Optimization Failed"
- Next in thread: hutch--: "Re: C/C++ Compiler's Optimization Failed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 21 Feb 2004 05:43:13 +0000 (UTC)
I agree with Jack. I should always depend on Intel VTune while I write
in assembly. It can be very difficult to write in assembly without using
C/C++'s help.
First, I write C/C++ code before I can convert C/C++ code into assembly
code. I remove some unnecessary instructions such as AND by reducing CPU's
clock. Use Intel VTune to test assembly code for maximum optimization and
performance. I have done many times while I am studying my own project in
assembly language.
--
Bryan Parkoff
"Jack Klein" <jackklein@spamcop.net> wrote in message
news:fqmd30h5a1aaet528eti7gqidrbhnu8ej4@4ax.com...
> On Sat, 21 Feb 2004 01:18:24 +0000 (UTC), "Bryan Parkoff"
> <bryan.nospam.parkoff@nospam.com> wrote in comp.lang.asm.x86:
>
> > I wrote C++ code below.
> >
> > VOID Set_Red(U_BYTE _Red, U_BYTE _Green, U_BYTE _Blue)
> > {
> > Red = (0x00 << 24) | (_Red << 16) | (_Green << 8) | _Blue;
> > }
>
> Of course the code you wrote happens to be illegal C++, but I don't
> suppose you care about that.
>
> > I used C/C++ Compiler's Optimization. The machine language shows
below.
> >
> > mov ecx, DWORD PTR [esp+0ch]
> > xor eax, eax
> > mov ah, BYTE PTR [esp+04h]
> > and ecx, 0ffh
> > mov al, BYTE PTR [esp+08h]
> > shl eax, 08h
> > or eax, ecx
> > mov DWORD PTR [0409500h], eax
> > ret
> >
> > I am shocked that C/C++ Compiler did not tune optimization very well
> > because partial register DOES EXIST!!
>
> I am shocked that all you have ever done since starting to post to
> usenet is complain. Intel's processors aren't good enough, the C and
> C++ languages weren't designed to meet your idea of what they should
> be, nobody's compiler is good enough for you.
>
> If you don't like the code generated by that compiler, try a different
> one. If you don't like the code generated by any compiler, write your
> own or do without.
>
> If you don't like Intel's processors, develop your own.
>
> And why are you complaining in an assembly language newsgroup about
> the code generated by a compiler? C and C++ compilers are really
> off-topic here, except perhaps for how to use their inline assembly
> support or how to link their code with assembly language code.
> Whatever C and C++ compilers do for C and C++ code is not an issue
> that belongs here.
>
> > My correction code should be below.
> >
> > mov eax, DWORD PTR [esp+04h]
> > shl eax, 08h
> > or eax, DWORD PTR [esp+08h]
> > shl eax, 08h
> > or eax, DWORD PTR [esp+0ch]
> > ret
> >
> > I am very concerned that all C/C++ Compiler does not do good job to
tune
> > optimization properly. I used Intel VTune to detect and discover many
hot
> > spots that they do include partial register. I did test on both Pentium
III
> > and Pentium IV. They do apply partial register that should be avoided.
>
> Frankly, that is not the job or a C or C++ compiler.
>
> > What is your recommendation?
>
> My recommendation is that you quit complaining about everything.
> Write your own compiler, then you can blame yourself when it misses
> something.
>
> > 1. Write C/C++ code in DEBUG version.
> > 2. Test C/C++ code on any computer to see if it works with NO BUG
> > (Optimization is not important YET!!)
> > 3. Change from DEBUG version to RELEASE version.
> > 4. Test C/C++ code on any computer to see if it works with NO BUG
> > (Optimization is ENABLED!!)
> > 5. Use VTune to discover hot spots including partial register.
> > 6. Convert C/C++ code into machine language in your own hands
manually.
> > 7. Link your existing C/C++ code and Machine code together.
> > 8. Test mixed C/C++ code and Machine code on any computer to see if
it
> > works with NO BUG.
> > 9. After all tests are done, it will be big IMPACT for improved
> > optimization.
>
> Improved optimization of WHAT???
>
> What application have you written that performed correctly and only
> failed to meet its requirements because it executed too slowly?
>
> Many assembly language programmers are interested in wringing the
> maximum performance out of a processor, that is usually the reason
> they program in assembly.
>
> If C and C++ compilers do not do a good enough job for you, then don't
> use them. Stop complaining about compilers unless you are going to
> write your own.
>
> --
> Jack Klein
> Home: http://JK-Technology.Com
> FAQs for
> comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
> comp.lang.c++ http://www.parashift.com/c++-faq-lite/
> alt.comp.lang.learn.c-c++
> http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
>
- Next message: hutch--: "Re: C/C++ Compiler's Optimization Failed"
- Previous message: Jack Klein: "Re: C/C++ Compiler's Optimization Failed"
- In reply to: Jack Klein: "Re: C/C++ Compiler's Optimization Failed"
- Next in thread: hutch--: "Re: C/C++ Compiler's Optimization Failed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|