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: Mined out of comp.std.c...



>> OK, last thought on the matter before I go slit my wrists in 
>> shame.
>
>Except that didn't work. I think I'll give up and go home - I can't seem
>to manage to redeem myself.
>
>Problem is I put 'setnc' as a quick hack and didn't notice it broke my
>non-overflow testcase. What I really needed was 'set carry xor overflow'
>but there's no primitive for that and I can't construct something out of
>set[n]o and sbb or adc.

Go grab superopt-2.5.tar.gz from the gnu tree, config it for intel
and run it to search for a sequence that evaluates 'maxs':

[pbarada: ~/src/superopt-2.5] > ./superopt -fmaxs -max-cost 5
Searching for { r = (signed_word) v0 > (signed_word) v1 ? v0 : v1; }
Superoptimizing at cost 1 2 3 4 5 failure.


Which indicates that the superoptimizer can not find a 5 instruction
sequence to do this.  Obviously if you crank up max-costs a bit and
let it run over the weekend it *might* find a sequence worth
investigating.  If your max function is *unsigned*, superopt finds a
batch of matches quite quickly:

[pbarada: ~/src/superopt-2.5] > ./superopt -fmaxu -max-cost 5
Searching for { r = (unsigned_word) v0 > (unsigned_word) v1 ? v0 : v1; }
Superoptimizing at cost 1 2 3 4 5
1:	r1:=sub_co(r1,r0)
	r0:=add_co(r0,r1)
	r2:=sub_cio(r2,r2)
	r2:=and_rc(r2,r1)
	r0:=sub_co(r0,r2)
2:	r1:=sub_co(r1,r0)
	r0:=add_co(r0,r1)
	r2:=sub_cio(r2,r2)
	r1:=and_rc(r1,r2)
	r0:=sub_co(r0,r1)
...


Have Fun!

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


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