[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

teaching gcc's optimiser new tricks



Currently if you ask gcc -O2 (tried on 3.0) to evaluate

  !a

it will give you code of the form:

	cmp	r4, #0
	movne	ip, #0
	moveq	ip, #1


how does one teach the optimiser that this is equivalent and 33% faster:

	rsbs     ip, r4, #1
	movls    ip, #0

(I've checked this with a loop 

    int value = 0;
    while (--value) {
      ...
    }

and it gives !a for all values of a)


Maybe I'm over-optimistic, but I would hope that the aggregate effect of small
gains where possible on common C operators would start to add up to slight
speed gains.

Nicholas Clark
-- 
Even better than the real thing:	http://nms-cgi.sourceforge.net/



Reply to: