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] |
Note that the current GCC release is 4.7.0.
This cast changes the meaning of the code, so it's not surprising that
you see different assembler instructions. The first case above will do
the multiplication in the type "unsigned long long". In the second case
the "unsigned char" values are zero-extended to int, and the
multiplication is done in the type "int". Then the "int" result is
sign-extended to "unsigned long long" for the addition.
In this case it's true that the compiler could convert the code as you
suggest, based on the knowledge that the int values are always in the
range 0 to 255.
However, it's not clear to me that using imulq would be better. My copy of the Intel optimization manual suggests that imull has slightly lower latency than imulq, so I think that in many cases imull would be preferred.
Best regards Daniel Marschall
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |