This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: G++ could optimize ASM code more


Daniel Marschall <daniel-marschall@viathinksoft.de> writes:

> I did understand that the compiler used "signed" multiplication
> instead of an unsigned one because char*char needs to be extended.
>
> Maybe I am wrong, but couldn't the compiler "know" that the result
> will be at least unsigned because unsigned * unsigned = unsigned ?

Well, but the rules of C say that the unsigned char values are
zero-extended to int, and then they are multiplied using a signed
multiplication.  So the result is not unsigned.  The compiler really
would have to do some sort of type or value based reasoning here to
determine that an unsigned multiplication would work also.

> Mh... good point. I do not know much about Assembler so I just thought
> the shorter the code the better.

Sadly, no.


> If imull is faster than imulq, then
> the question is, if imull+movslq is still faster than a single
> imulq. Do you know where I can find these informations for my CPU
> (Intel Xeon X3440)? I was searching for a table which shows how many
> CPU-ticks the imull, imulq and movslq need, but yet I have not found
> one.
>
> My Linux is 2.6.32-5-amd64 #1 SMP Mon Jan 16 16:22:28 UTC 2012 x86_64
> GNU/Linux .
>
> And the CPU is "Intel(R) Xeon(R) CPU X3440  @ 2.53GHz". (I hope the
> "amd64" version of Debian is the correct one, or should our admin have
> installed the "ia64" variant since it is an Intel CPU?)

Look for the Intel Optimization Manual on intel.com.  The appendixes
have latency and throughput information for the instruction set on
various Intel processors.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]