Greg Ercolano wrote: > MacArthur, Ian (SELEX) (UK) wrote: >> I've looked at the code generated for integer mod operations >> in the past, and a lot of compilers make a real mess of it.. > > Really? Noticeably? > > % g++ -g -c -Wa,-adhln -O1 foo.C | more > [..] > 4:foo.C **** x = x % 20; // <-- > 31 .loc 1 4 0 > 32 0013 BA14000000 movl $20, %edx > 33 0018 89D1 movl %edx, %ecx > 34 001a 99 cltd > 35 001b F7F9 idivl %ecx > [..] > > Removing -O1 is pretty much the same result.
Are you using a pretty old gcc or a 32-bit machine, Greg? My gcc3.1 and later up to 4.1 optimize the % 20 by doing shifting operations instead. You only get idivl if you use two arbitrary variables. -- Gonzalo Garramuño [EMAIL PROTECTED] AMD4400 - ASUS48N-E GeForce7300GT Kubuntu Edgy _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
