surprising optimization of comparison operations for __int128_t

Andrew Haley aph@redhat.com
Fri Jul 9 11:04:00 GMT 2010


On 07/09/2010 11:34 AM, Mathieu Lacage wrote:
> On Fri, Jul 9, 2010 at 11:33 AM, Andrew Haley <aph@redhat.com> wrote:
> 
>> g++ seems to be generating a specialization of run_cmp() in the
>> __int128_t case, with the parameters a and b fixed at a=1 and b=2, in
>> an attempt to do some constant propagation.  This ought to help, but
>> unfortunately the back-end generates worse code for the specialized
>> case.
> 
> Interesting: this is what the clone thing is about then. I found this
> issue only because I am actually doing some benchmarking and am trying
> to evaluate the average cost of a 128bit comparison (compared to other
> things). Do you know of a way to convince gcc to not generate this
> specialization so that I really measure the generic comparison
> function ? I guess that I could pull the constant values from the
> command line to ensure that gcc does not generate this specialization
> but is there a better way ?

Sure, just don't use constants for 1 and 2.  Putting them as variables
in file scope ought to do it.

int one = 1;

etc.

Andrew.

P.S.  Please cc: me on copies, don't send a separate mail.



More information about the Gcc-help mailing list